Navigation

This article explains the new features in Pyramid version 1.2 as
compared to its predecessor, Pyramid 1.1. It also documents backwards
incompatibilities between the two versions and deprecations added to Pyramid
1.2, as well as software dependency changes and notable documentation
additions.

A tween is used to wrap the Pyramid router's primary request handling
function. This is a feature that can be used by Pyramid framework extensions,
to provide, for example, view timing support and can provide a convenient
place to hang bookkeeping code. Tweens are a little like WSGImiddleware, but have access to Pyramid functionality such as renderers
and a full-featured request object.

All scaffolds now use the pyramid_tm package rather than the
repoze.tm2middleware to manage transaction management.

The ZODB scaffold now uses the pyramid_zodbconn package rather than the
repoze.zodbconn package to provide ZODB integration.

All scaffolds now use the pyramid_debugtoolbar package rather than the
WebError package to provide interactive debugging features.

Projects created via a scaffold no longer depend on the WebError package
at all; configuration in the production.ini file which used to require
its error_catchermiddleware has been removed. Configuring
error catching / email sending is now the domain of the pyramid_exclog
package (see http://docs.pylonsproject.org/projects/pyramid_exclog/dev/).

All scaffolds now send the cache_max_age parameter to the
add_static_view method.

The [pshell] section in an ini configuration file now treats a
setup key as a dotted name that points to a callable that is passed the
bootstrap environment. It can mutate the environment as necessary during a
pasterpshell session. This feature is described in
Writing a Script.

A new configuration setting named pyramid.includes is now available.
It is described in Including Packages.

Added a pyramid.security.NO_PERMISSION_REQUIRED constant for use in
permission= statements to view configuration. This constant has a
value of the string __no_permission_required__. This string value was
previously referred to in documentation; now the documentation uses the
constant.

The pyramid.events.BeforeRender event now has an attribute named
rendering_val. This can be used to introspect the value returned by a
view in a BeforeRender subscriber.

The Pyramid debug logger now uses the standard logging configuration
(usually set up by Paste as part of startup). This means that output from
e.g. debug_notfound, debug_authorization, etc. will go to the
normal logging channels. The logger name of the debug logger will be the
package name of the caller of the Configurator's constructor.

A new attribute is available on request objects: exc_info. Its value
will be None until an exception is caught by the Pyramid router, after
which it will be the result of sys.exc_info().

Pyramid no longer eagerly commits some default configuration statements at
Configurator construction time, which permits values passed in as
constructor arguments (e.g. authentication_policy and
authorization_policy) to override the same settings obtained via the
pyramid.config.Configurator.include() method.

Better Mako rendering exceptions; the template line which caused the error
is now shown when a Mako rendering raises an exception.

The RemoteUserAuthenticationPolicy,
AuthTktAuthenticationPolicy, and
SessionAuthenticationPolicy constructors
now accept an additional keyword argument named debug. By default,
this keyword argument is False. When it is True, debug information
will be sent to the Pyramid debug logger (usually on stderr) when the
authenticated_userid or effective_principals method is called on
any of these policies. The output produced can be useful when trying to
diagnose authentication-related problems.

New view predicate: match_param. Example: a view added via
config.add_view(aview,match_param='action=edit') will be called only
when the request.matchdict has a value inside it named action with
a value of edit.

Undeprecated pyramid.traversal.find_model,
pyramid.traversal.model_path, pyramid.traversal.model_path_tuple,
and pyramid.url.model_url, which were all deprecated in Pyramid 1.0.
There's just not much cost to keeping them around forever as aliases to
their renamed resource_* prefixed functions.

Undeprecated pyramid.view.bfg_view, which was deprecated in Pyramid
1.0. This is a low-cost alias to pyramid.view.view_config which we'll
just keep around forever.

All Pyramid-related deployment settings (e.g. debug_all,
debug_notfound) are now meant to be prefixed with the prefix
pyramid.. For example: debug_all -> pyramid.debug_all. The
old non-prefixed settings will continue to work indefinitely but supplying
them may print a deprecation warning. All scaffolds and tutorials have
been changed to use prefixed settings.

The deployment settings dictionary now raises a deprecation warning
when you attempt to access its values via __getattr__ instead of via
__getitem__.

It may be necessary to more strictly order configuration route and view
statements when using an "autocommitting" Configurator. In the
past, it was possible to add a view which named a route name before adding
a route with that name when you used an autocommitting configurator. For
example:

This won't effect "normal" users, only people who have legacy BFG codebases
that used an autommitting configurator and possibly tests that use the
configurator API (the configurator returned by
pyramid.testing.setUp() is an autocommitting configurator). The
right way to get around this is to use a default non-autocommitting
configurator, which does not have these directive ordering requirements:

Narrative and API documentation which used the route_url,
route_path, resource_url, static_url, and current_route_url
functions in the pyramid.url package have now been changed to use
eponymous methods of the request instead.