Pyramid1.10的新功能¶
本文解释了 Pyramid 与前代版本相比,1.10版 Pyramid 1.9。它还记录了两个版本之间的向后不兼容以及添加到 Pyramid 1.10,以及软件依赖性更改和显著的文档添加。
备注
这个版本是最后一个计划的支持Python2.7的功能版本。在至少2020-01-01之前,当python 2.7达到使用寿命结束时,错误修复将继续被反向移植。1.x系列Pyramid将审查和接受新的功能和背面端口,但新的开发将集中在2.xPyramid上。
功能添加¶
添加对python 3.7的支持。在python 3.8上添加允许失败的测试。参见https://github.com/pylons/pyramid/pull/3333
添加上下文管理器
pyramid.config.Configurator.route_prefix_context()
为了方便设置route_prefix
对于pyramid.config.Configurator.include()
和pyramid.config.Configurator.add_route()
在上下文中调用。参见https://github.com/pylons/pyramid/pull/3279增加了
pyramid.config.Configurator.add_accept_view_order()
指令,允许用户在多个视图匹配等不明确情况下指定媒体类型首选项。默认的排序是为更喜欢人类可读的HTML/文本响应而不是JSON的媒体类型定义的。参见https://github.com/pylons/pyramid/pull/3326支持中的媒体类型列表
accept
中使用的谓词pyramid.config.Configurator.add_route()
. 参见https://github.com/pylons/pyramid/pull/3326已添加
pyramid.session.JSONSerializer
。看见 升级会话序列化 有关此功能的详细信息,请参阅。请参阅https://github.com/Pylons/pyramid/pull/3353修改内置会话实现以支持
SameSite
cookie上的选项并将默认值设置为'Lax'
. 这种影响pyramid.session.BaseCookieSessionFactory()
,pyramid.session.SignedCookieSessionFactory()
和pyramid.session.UnencryptedCookieSessionFactoryConfig()
. 参见https://github.com/pylons/pyramid/pull/3300修改
pyramid.authentication.AuthTktAuthenticationPolicy
和pyramid.csrf.CookieCSRFStoragePolicy
支持SameSite
cookies上的选项,并将默认值设置为'Lax'
. 参见https://github.com/pylons/pyramid/pull/3319新增
pyramid.httpexceptions.HTTPPermanentRedirect
HTTP 308重定向的异常/响应对象。参见https://github.com/pylons/pyramid/pull/3302添加
_depth
和_category
所有金星装饰师的参数。这个_category
参数可用于影响在执行config.scan(..., category=...)
具有特定类别。这个_depth
当用自己的方法包装装饰器时,应该使用参数。这一变化影响pyramid.view.view_config()
,pyramid.view.exception_view_config()
,pyramid.view.forbidden_view_config()
,pyramid.view.notfound_view_config()
,pyramid.events.subscriber()
和pyramid.response.response_adapter()
装饰工。请参阅https://github.com/pylons/pyramid/pull/3105和https://github.com/pylons/pyramid/pull/3122修复
pyramid.request.Request
使用后的类名pyramid.request.Request.set_property()
或pyramid.config.Configurator.add_request_method()
这样str(request.__class__)
将表现为pyramid.request.Request
而不是pyramid.util.Request
. 参见https://github.com/pylons/pyramid/pull/3129添加
registry
参数pyramid.renderers.get_renderer()
允许用户在渲染器查找期间避免线程局部变量。参见https://github.com/pylons/pyramid/pull/3358内
pshell
,允许用户定义setup
函数是一个生成器,在这种情况下,它可以包装命令的生命周期。参见https://github.com/pylons/pyramid/pull/3318内
pshell
,变量由[pshell]
设置在用户定义的setup
功能。参见https://github.com/pylons/pyramid/pull/3318在
cherrypy_server_runner
更喜欢从cheroot
打包旧版导入源 cherrypy.wsgiserver . 参见https://github.com/pylons/pyramid/pull/3235Pyramid 的测试套件不再与通用车轮一起分发。参见https://github.com/pylons/pyramid/pull/3387
所有的python代码现在都使用
black
. 参见https://github.com/pylons/pyramid/pull/3388
废弃¶
这个
pyramid.interfaces.ISession
接口将移动到需要JSON可序列化对象的 Pyramid 2.0版本。看见 升级会话序列化 有关此更改的详细信息,请参阅。请参阅https://github.com/Pylons/pyramid/pull/3353这个
pyramid.session.signed_serialize()
和pyramid.session.signed_deserialize()
函数将在中删除 Pyramid 2.0,连同拆除pyramid.session.UnencryptedCookieSessionFactoryConfig()
在中被弃用 Pyramid 1.5。请切换到使用pyramid.session.SignedCookieSessionFactory()
,如果仍在使用这些功能,则复制代码或其他会话实现。参见https://github.com/pylons/pyramid/pull/3353中的媒体范围已弃用
accept
的参数pyramid.config.Configurator.add_route()
. 使用显式媒体类型列表add_route
支持多种类型。参见https://github.com/pylons/pyramid/pull/3326中的媒体范围已弃用
accept
的参数pyramid.config.Configurator.add_view()
. 范围到没有替换add_view
但经过多次讨论,工作流在面对各种客户端提供的Accept
标题。参见https://github.com/pylons/pyramid/pull/3326
向后不兼容¶
远离的
pyramid.config.Configurator.set_request_property
从那以后就被弃用了 Pyramid 1.5。代替使用pyramid.config.Configurator.add_request_method()
具有reify=True
或property=True
. 参见https://github.com/pylons/pyramid/pull/3368在python 3.4+
repoze.lru
相关性已删除。如果你直接在你的应用程序中使用这个软件包,你应该确保你在你的项目中直接依赖它。参见https://github.com/pylons/pyramid/pull/3140移除
permission
论证从pyramid.config.Configurator.add_route()
. 这是从中删除的功能留下的参数 Pyramid 1.5,此后无任何影响。参见https://github.com/pylons/pyramid/pull/3299已将内置会话实现修改为
SameSite='Lax'
饼干。这种影响pyramid.session.BaseCookieSessionFactory()
,pyramid.session.SignedCookieSessionFactory()
和pyramid.session.UnencryptedCookieSessionFactoryConfig()
. 参见https://github.com/pylons/pyramid/pull/3300中定义的变量
[pshell]
设置部分将不再覆盖由setup
功能。参见https://github.com/pylons/pyramid/pull/3318pyramid.config.Configurator.add_notfound_view()
使用默认重定向类异常pyramid.httpexceptions.HTTPTemporaryRedirect
而不是上一个pyramid.httpexceptions.HTTPFound
. 参见https://github.com/pylons/pyramid/pull/3328移除
principal
关键字参数来自pyramid.security.remember()
从那以后就被弃用了 Pyramid 1.6替换为userid
参数。参见https://github.com/pylons/pyramid/pull/3369移除
pyramid.tests
用于包含Pyramid测试套件的子包。这些更改还更改了存储库的格式,以便将代码移动到src
文件夹。参见https://github.com/pylons/pyramid/pull/3387
文档增强功能¶
广告支持阅读文档道德广告。请参阅https://github.com/pylons/pyramid/pull/3360和https://docs.read the docs.io/en/latest/advertising/ethical-advertising.html
添加对alembic的支持到Pyramid烹饪者炼金术烹饪者,并更新wiki2教程来解释它是如何工作的。参见https://github.com/pylons/pyramid/pull/3307和https://github.com/pylons/pyramid-cookiecutter-alchemy/pull/7
在setup.py中将sphinx凹凸到大于等于1.7.4以支持
emphasize-lines
在PDF中,为Xeletex支持铺平道路。请参阅https://github.com/pylons/pyramid/pull/3271、https://github.com/pylons/pyramid/issues/667和https://github.com/pylons/pyramid/issues/2572。在快速教程中添加了额外的测试。参见https://github.com/pylons/pyramid/pull/3375