Next Release ============ Major Backward Incompatibilities -------------------------------- - Pyramid has dropped native support for the Mako and Chameleon renderers. To re-add support for these renderers into existing projects there are 3 steps: - Add `pyramid_mako` and/or `pyramid_chameleon` as dependencies by adding them to the `install_requires` section of the package's `setup.py`:: setup( #... install_requires=[ 'pyramid_mako', # new dependency 'pyramid_chameleon', # new dependency 'pyramid', #... ], ) - Update instances of the ``pyramid.config.Configurator`` to include the required addons:: config.include('pyramid_chameleon') config.include('pyramid_mako') - If any unit tests are invoking either ``pyramid.renderers.render()`` or ``pyramid.renderers.render_to_response()`` with either Mako or Chameleon templates then the ``pyramid.config.Configurator`` instance at the root of the unit test should be also be updated to include the addons, as shown above. For example:: config = pyramid.testing.setUp() config.include('pyramid_mako') result = pyramid.renderers.render('mypkg:templates/home.mako', {}) 1.5a1 (2013-08-30) ================== Features -------- - A new http exception subclass named ``pyramid.httpexceptions.HTTPSuccessful`` was added. You can use this class as the ``context`` of an exception view to catch all 200-series "exceptions" (e.g. "raise HTTPOk"). This also allows you to catch *only* the ``HTTPOk`` exception itself; previously this was impossible because a number of other exceptions (such as ``HTTPNoContent``) inherited from ``HTTPOk``, but now they do not. - You can now generate "hybrid" urldispatch/traversal URLs more easily by using the new ``route_name``, ``route_kw`` and ``route_remainder_name`` arguments to ``request.resource_url`` and ``request.resource_path``. See the new section of the "Combining Traversal and URL Dispatch" documentation chapter entitled "Hybrid URL Generation". - It is now possible to escape double braces in Pyramid scaffolds (unescaped, these represent replacement values). You can use ``\{\{a\}\}`` to represent a "bare" ``{{a}}``. See https://github.com/Pylons/pyramid/pull/862 - Add ``localizer`` and ``locale_name`` properties (reified) to the request. See https://github.com/Pylons/pyramid/issues/508. Note that the ``pyramid.i18n.get_localizer`` and ``pyramid.i18n.get_locale_name`` functions now simply look up these properties on the request. - Add ``pdistreport`` script, which prints the Python version in use, the Pyramid version in use, and the version number and location of all Python distributions currently installed. - Add the ability to invert the result of any view, route, or subscriber predicate using the ``not_`` class. For example:: from pyramid.config import not_ @view_config(route_name='myroute', request_method=not_('POST')) def myview(request): ... The above example will ensure that the view is called if the request method is not POST (at least if no other view is more specific). The :class:`pyramid.config.not_` class can be used against any value that is a predicate value passed in any of these contexts: - ``pyramid.config.Configurator.add_view`` - ``pyramid.config.Configurator.add_route`` - ``pyramid.config.Configurator.add_subscriber`` - ``pyramid.view.view_config`` - ``pyramid.events.subscriber`` - ``scripts/prequest.py``: add support for submitting ``PUT`` and ``PATCH`` requests. See https://github.com/Pylons/pyramid/pull/1033. add support for submitting ``OPTIONS`` and ``PROPFIND`` requests, and allow users to specify basic authentication credentials in the request via a ``--login`` argument to the script. See https://github.com/Pylons/pyramid/pull/1039. - ``ACLAuthorizationPolicy`` supports ``__acl__`` as a callable. This removes the ambiguity between the potential ``AttributeError`` that would be raised on the ``context`` when the property was not defined and the ``AttributeError`` that could be raised from any user-defined code within a dynamic property. It is recommended to define a dynamic ACL as a callable to avoid this ambiguity. See https://github.com/Pylons/pyramid/issues/735. - Allow a protocol-relative URL (e.g. ``//example.com/images``) to be passed to ``pyramid.config.Configurator.add_static_view``. This allows externally-hosted static URLs to be generated based on the current protocol. - The ``AuthTktAuthenticationPolicy`` has two new options to configure its domain usage: * ``parent_domain``: if set the authentication cookie is set on the parent domain. This is useful if you have multiple sites sharing the same domain. * ``domain``: if provided the cookie is always set for this domain, bypassing all usual logic. See https://github.com/Pylons/pyramid/pull/1028, https://github.com/Pylons/pyramid/pull/1072 and https://github.com/Pylons/pyramid/pull/1078. - The ``AuthTktAuthenticationPolicy`` now supports IPv6 addresses when using the ``include_ip=True`` option. This is possibly incompatible with alternative ``auth_tkt`` implementations, as the specification does not define how to properly handle IPv6. See https://github.com/Pylons/pyramid/issues/831. - Make it possible to use variable arguments via ``pyramid.paster.get_appsettings``. This also allowed the generated ``initialize_db`` script from the ``alchemy`` scaffold to grow support for options in the form ``a=1 b=2`` so you can fill in values in a parameterized ``.ini`` file, e.g. ``initialize_myapp_db etc/development.ini a=1 b=2``. See https://github.com/Pylons/pyramid/pull/911 - The ``request.session.check_csrf_token()`` method and the ``check_csrf`` view predicate now take into account the value of the HTTP header named ``X-CSRF-Token`` (as well as the ``csrf_token`` form parameter, which they always did). The header is tried when the form parameter does not exist. - View lookup will now search for valid views based on the inheritance hierarchy of the context. It tries to find views based on the most specific context first, and upon predicate failure, will move up the inheritance chain to test views found by the super-type of the context. In the past, only the most specific type containing views would be checked and if no matching view could be found then a PredicateMismatch would be raised. Now predicate mismatches don't hide valid views registered on super-types. Here's an example that now works: .. code-block:: python class IResource(Interface): ... @view_config(context=IResource) def get(context, request): ... @view_config(context=IResource, request_method='POST') def post(context, request): ... @view_config(context=IResource, request_method='DELETE') def delete(context, request): ... @implementer(IResource) class MyResource: ... @view_config(context=MyResource, request_method='POST') def override_post(context, request): ... Previously the override_post view registration would hide the get and delete views in the context of MyResource -- leading to a predicate mismatch error when trying to use GET or DELETE methods. Now the views are found and no predicate mismatch is raised. See https://github.com/Pylons/pyramid/pull/786 and https://github.com/Pylons/pyramid/pull/1004 and https://github.com/Pylons/pyramid/pull/1046 - The ``pserve`` command now takes a ``-v`` (or ``--verbose``) flag and a ``-q`` (or ``--quiet``) flag. Output from running ``pserve`` can be controlled using these flags. ``-v`` can be specified multiple times to increase verbosity. ``-q`` sets verbosity to ``0`` unconditionally. The default verbosity level is ``1``. - The ``alchemy`` scaffold tests now provide better coverage. See https://github.com/Pylons/pyramid/pull/1029 - The ``pyramid.config.Configurator.add_route`` method now supports being called with an external URL as pattern. See https://github.com/Pylons/pyramid/issues/611 and the documentation section in the "URL Dispatch" chapter entitled "External Routes" for more information. Bug Fixes --------- - It was not possible to use ``pyramid.httpexceptions.HTTPException`` as the ``context`` of an exception view as very general catchall for http-related exceptions when you wanted that exception view to override the default exception view. See https://github.com/Pylons/pyramid/issues/985 - When the ``pyramid.reload_templates`` setting was true, and a Chameleon template was reloaded, and the renderer specification named a macro (e.g. ``foo#macroname.pt``), renderings of the template after the template was reloaded due to a file change would produce the entire template body instead of just a rendering of the macro. See https://github.com/Pylons/pyramid/issues/1013. - Fix an obscure problem when combining a virtual root with a route with a ``*traverse`` in its pattern. Now the traversal path generated in such a configuration will be correct, instead of an element missing a leading slash. - Fixed a Mako renderer bug returning a tuple with a previous defname value in some circumstances. See https://github.com/Pylons/pyramid/issues/1037 for more information. - Make the ``pyramid.config.assets.PackageOverrides`` object implement the API for ``__loader__`` objects specified in PEP 302. Proxies to the ``__loader__`` set by the importer, if present; otherwise, raises ``NotImplementedError``. This makes Pyramid static view overrides work properly under Python 3.3 (previously they would not). See https://github.com/Pylons/pyramid/pull/1015 for more information. - ``mako_templating``: added defensive workaround for non-importability of ``mako`` due to upstream ``markupsafe`` dropping Python 3.2 support. Mako templating will no longer work under the combination of MarkupSafe 0.17 and Python 3.2 (although the combination of MarkupSafe 0.17 and Python 3.3 or any supported Python 2 version will work OK). - Spaces and dots may now be in mako renderer template paths. This was broken when support for the new makodef syntax was added in 1.4a1. See https://github.com/Pylons/pyramid/issues/950 - ``pyramid.debug_authorization=true`` will now correctly print out ``Allowed`` for views registered with ``NO_PERMISSION_REQUIRED`` instead of invoking the ``permits`` method of the authorization policy. See https://github.com/Pylons/pyramid/issues/954 - Pyramid failed to install on some systems due to being packaged with some test files containing higher order characters in their names. These files have now been removed. See https://github.com/Pylons/pyramid/issues/981 - ``pyramid.testing.DummyResource`` didn't define ``__bool__``, so code under Python 3 would use ``__len__`` to find truthiness; this usually caused an instance of DummyResource to be "falsy" instead of "truthy". See https://github.com/Pylons/pyramid/pull/1032 - The ``alchemy`` scaffold would break when the database was MySQL during tables creation. See https://github.com/Pylons/pyramid/pull/1049 - The ``current_route_url`` method now attaches the query string to the URL by default. See https://github.com/Pylons/pyramid/issues/1040 - Make ``pserve.cherrypy_server_runner`` Python 3 compatible. See https://github.com/Pylons/pyramid/issues/718 Backwards Incompatibilities --------------------------- - Modified the ``current_route_url`` method in pyramid.Request. The method previously returned the URL without the query string by default, it now does attach the query string unless it is overriden. - The ``route_url`` and ``route_path`` APIs no longer quote ``/`` to ``%2F`` when a replacement value contains a ``/``. This was pointless, as WSGI servers always unquote the slash anyway, and Pyramid never sees the quoted value. - It is no longer possible to set a ``locale_name`` attribute of the request, nor is it possible to set a ``localizer`` attribute of the request. These are now "reified" properties that look up a locale name and localizer respectively using the machinery described in the "Internationalization" chapter of the documentation. - If you send an ``X-Vhm-Root`` header with a value that ends with a slash (or any number of slashes), the trailing slash(es) will be removed before a URL is generated when you use use ``request.resource_url`` or ``request.resource_path``. Previously the virtual root path would not have trailing slashes stripped, which would influence URL generation. - The ``pyramid.interfaces.IResourceURL`` interface has now grown two new attributes: ``virtual_path_tuple`` and ``physical_path_tuple``. These should be the tuple form of the resource's path (physical and virtual).