What's New in Pyramid 1.10¶
This article explains the new features in Pyramid version 1.10 as compared to its predecessor, Pyramid 1.9. It also documents backwards incompatibilities between the two versions and deprecations added to Pyramid 1.10, as well as software dependency changes and notable documentation additions.
注釈
This release is the last planned feature release to support Python 2.7. Bug fixes will continue to be backported until at least 2020-01-01 when Python 2.7 reaches end of life. New features and backports will be reviewed and accepted for the 1.x series of Pyramid but new development will be focused on Pyramid 2.x.
Feature Additions¶
Add support for Python 3.7. Add testing on Python 3.8 with allowed failures. See https://github.com/Pylons/pyramid/pull/3333
Add a context manager
pyramid.config.Configurator.route_prefix_context()
to allow for convenient setting of theroute_prefix
forpyramid.config.Configurator.include()
andpyramid.config.Configurator.add_route()
calls inside the context. See https://github.com/Pylons/pyramid/pull/3279Added the
pyramid.config.Configurator.add_accept_view_order()
directive, allowing users to specify media type preferences in ambiguous situations such as when several views match. A default ordering is defined for media types that prefers human-readable html/text responses over JSON. See https://github.com/Pylons/pyramid/pull/3326Support a list of media types in the
accept
predicate used inpyramid.config.Configurator.add_route()
. See https://github.com/Pylons/pyramid/pull/3326Added
pyramid.session.JSONSerializer
. See Upgrading Session Serialization for more information about this feature. See https://github.com/Pylons/pyramid/pull/3353Modify the builtin session implementations to support
SameSite
options on cookies and set the default to'Lax'
. This affectspyramid.session.BaseCookieSessionFactory()
,pyramid.session.SignedCookieSessionFactory()
, andpyramid.session.UnencryptedCookieSessionFactoryConfig()
. See https://github.com/Pylons/pyramid/pull/3300Modify
pyramid.authentication.AuthTktAuthenticationPolicy
andpyramid.csrf.CookieCSRFStoragePolicy
to support theSameSite
option on cookies and set the default to'Lax'
. See https://github.com/Pylons/pyramid/pull/3319Added new
pyramid.httpexceptions.HTTPPermanentRedirect
exception/response object for a HTTP 308 redirect. See https://github.com/Pylons/pyramid/pull/3302Add
_depth
and_category
arguments to all of the venusian decorators. The_category
argument can be used to affect which actions are registered when performing aconfig.scan(..., category=...)
with a specific category. The_depth
argument should be used when wrapping the decorator in your own. This change affectspyramid.view.view_config()
,pyramid.view.exception_view_config()
,pyramid.view.forbidden_view_config()
,pyramid.view.notfound_view_config()
,pyramid.events.subscriber()
andpyramid.response.response_adapter()
decorators. See https://github.com/Pylons/pyramid/pull/3105 and https://github.com/Pylons/pyramid/pull/3122Fix the
pyramid.request.Request
class name after usingpyramid.request.Request.set_property()
orpyramid.config.Configurator.add_request_method()
such that thestr(request.__class__)
would appear aspyramid.request.Request
instead ofpyramid.util.Request
. See https://github.com/Pylons/pyramid/pull/3129Add a
registry
argument topyramid.renderers.get_renderer()
to allow users to avoid threadlocals during renderer lookup. See https://github.com/Pylons/pyramid/pull/3358Within
pshell
, allow the user-definedsetup
function to be a generator, in which case it may wrap the command's lifecycle. See https://github.com/Pylons/pyramid/pull/3318Within
pshell
, variables defined by the[pshell]
settings are available within the user-definedsetup
function. See https://github.com/Pylons/pyramid/pull/3318In
cherrypy_server_runner
, prefer imports from thecheroot
package over the legacy imports from cherrypy.wsgiserver. See https://github.com/Pylons/pyramid/pull/3235Pyramid's test suite is no longer distributed with the universal wheel. See https://github.com/Pylons/pyramid/pull/3387
All Python code is now formatted automatically using
black
. See https://github.com/Pylons/pyramid/pull/3388
Deprecations¶
The
pyramid.interfaces.ISession
interface will move to require JSON-serializable objects in Pyramid 2.0. See Upgrading Session Serialization for more information about this change. See https://github.com/Pylons/pyramid/pull/3353The
pyramid.session.signed_serialize()
andpyramid.session.signed_deserialize()
functions will be removed in Pyramid 2.0, along with the removal ofpyramid.session.UnencryptedCookieSessionFactoryConfig()
which was deprecated in Pyramid 1.5. Please switch to using thepyramid.session.SignedCookieSessionFactory()
, copying the code, or another session implementation if you're still using these features. See https://github.com/Pylons/pyramid/pull/3353Media ranges are deprecated in the
accept
argument ofpyramid.config.Configurator.add_route()
. Use a list of explicit media types toadd_route
to support multiple types. See https://github.com/Pylons/pyramid/pull/3326Media ranges are deprecated in the
accept
argument ofpyramid.config.Configurator.add_view()
. There is no replacement for ranges toadd_view
, but after much discussion the workflow is fundamentally ambiguous in the face of various client-supplied values for theAccept
header. See https://github.com/Pylons/pyramid/pull/3326
Backward Incompatibilities¶
Removed
pyramid.config.Configurator.set_request_property
which had been deprecated since Pyramid 1.5. Instead usepyramid.config.Configurator.add_request_method()
withreify=True
orproperty=True
. See https://github.com/Pylons/pyramid/pull/3368On Python 3.4+ the
repoze.lru
dependency is dropped. If you were using this package directly in your apps you should make sure that you are depending on it directly within your project. See https://github.com/Pylons/pyramid/pull/3140Remove the
permission
argument frompyramid.config.Configurator.add_route()
. This was an argument left over from a feature removed in Pyramid 1.5 and has had no effect since then. See https://github.com/Pylons/pyramid/pull/3299Modified the builtin session implementations to set
SameSite='Lax'
on cookies. This affectspyramid.session.BaseCookieSessionFactory()
,pyramid.session.SignedCookieSessionFactory()
, andpyramid.session.UnencryptedCookieSessionFactoryConfig()
. See https://github.com/Pylons/pyramid/pull/3300Variables defined in the
[pshell]
section of the settings will no longer override those set by thesetup
function. See https://github.com/Pylons/pyramid/pull/3318pyramid.config.Configurator.add_notfound_view()
uses default redirect class exceptionpyramid.httpexceptions.HTTPTemporaryRedirect
instead of previouspyramid.httpexceptions.HTTPFound
. See https://github.com/Pylons/pyramid/pull/3328Removed the
principal
keyword argument frompyramid.security.remember()
which had been deprecated since Pyramid 1.6 and replaced by theuserid
argument. See https://github.com/Pylons/pyramid/pull/3369Removed the
pyramid.tests
subpackage that used to contain the Pyramid test suite. These changes also changed the format of the repository to move the code into asrc
folder. See https://github.com/Pylons/pyramid/pull/3387
Documentation Enhancements¶
Ad support for Read The Docs Ethical Ads. See https://github.com/Pylons/pyramid/pull/3360 and https://docs.readthedocs.io/en/latest/advertising/ethical-advertising.html
Add support for alembic to the pyramid-cookiecutter-alchemy cookiecutter and update the wiki2 tutorial to explain how it works. See https://github.com/Pylons/pyramid/pull/3307 and https://github.com/Pylons/pyramid-cookiecutter-alchemy/pull/7
Bump Sphinx to >= 1.7.4 in setup.py to support
emphasize-lines
in PDFs and to pave the way for xelatex support. See https://github.com/Pylons/pyramid/pull/3271, https://github.com/Pylons/pyramid/issues/667, and https://github.com/Pylons/pyramid/issues/2572Added extra tests to the quick tutorial. See https://github.com/Pylons/pyramid/pull/3375