Steve Piercy
2016-01-03 a46b07c81252c12821fe5811a41e24799bd8eb34
commit | author | age
a46b07 1 What's New in Pyramid 1.6
bfe000 2 =========================
CM 3
4 This article explains the new features in :app:`Pyramid` version 1.6 as
a46b07 5 compared to its predecessor, :app:`Pyramid` 1.5. It also documents backwards
bfe000 6 incompatibilities between the two versions and deprecations added to
CM 7 :app:`Pyramid` 1.6, as well as software dependency changes and notable
8 documentation additions.
9
a46b07 10
bfe000 11 Backwards Incompatibilities
CM 12 ---------------------------
13
a46b07 14 - IPython and BPython support have been removed from pshell in the core. To
SP 15   continue using them on Pyramid 1.6+, you must install the binding packages
16   explicitly. One way to do this is by adding ``pyramid_ipython`` (or
17   ``pyramid_bpython``) to the ``install_requires`` section of your package's
18   ``setup.py`` file, then re-running ``setup.py develop``::
850f3f 19
MM 20     setup(
21         #...
22         install_requires=[
23             'pyramid_ipython',         # new dependency
24             'pyramid',
25             #...
26         ],
27     )
28
bfe000 29 - ``request.response`` will no longer be mutated when using the
a46b07 30   :func:`~pyramid.renderers.render_to_response` API. It is now necessary to
SP 31   pass in a ``response=`` argument to
32   :func:`~pyramid.renderers.render_to_response` if you wish to supply the
33   renderer with a custom response object. If you do not pass one, then a
34   response object will be created using the current response factory. Almost
35   all renderers mutate the ``request.response`` response object (for example,
36   the JSON renderer sets ``request.response.content_type`` to
37   ``application/json``). However, when invoking ``render_to_response``, it is
38   not expected that the response object being returned would be the same one
39   used later in the request. The response object returned from
40   ``render_to_response`` is now explicitly different from ``request.response``.
41   This does not change the API of a renderer. See
bfe000 42   https://github.com/Pylons/pyramid/pull/1563
CM 43
44
45 Feature Additions
46 -----------------
47
a46b07 48 - Python 3.5 and pypy3 compatibility.
SP 49
50 - ``pserve --reload`` will no longer crash on syntax errors. See
51   https://github.com/Pylons/pyramid/pull/2044
850f3f 52
MM 53 - Cache busting for static resources has been added and is available via a new
a46b07 54   :meth:`pyramid.config.Configurator.add_cache_buster` API. Core APIs are
SP 55   shipped for both cache busting via query strings and via asset manifests for
56   integrating into custom asset pipelines. See
57   https://github.com/Pylons/pyramid/pull/1380 and
850f3f 58   https://github.com/Pylons/pyramid/pull/1583 and
MM 59   https://github.com/Pylons/pyramid/pull/2171
bfe000 60
CM 61 - Assets can now be overidden by an absolute path on the filesystem when using
62   the :meth:`~pyramid.config.Configurator.override_asset` API. This makes it
63   possible to fully support serving up static content from a mutable directory
64   while still being able to use the :meth:`~pyramid.request.Request.static_url`
65   API and :meth:`~pyramid.config.Configurator.add_static_view`.  Previously it
66   was not possible to use :meth:`~pyramid.config.Configurator.add_static_view`
67   with an absolute path **and** generate urls to the content. This change
68   replaces the call, ``config.add_static_view('/abs/path', 'static')``, with
69   ``config.add_static_view('myapp:static', 'static')`` and
70   ``config.override_asset(to_override='myapp:static/',
71   override_with='/abs/path/')``. The ``myapp:static`` asset spec is completely
a46b07 72   made up and does not need to exist—it is used for generating URLs via
SP 73   ``request.static_url('myapp:static/foo.png')``. See
bfe000 74   https://github.com/Pylons/pyramid/issues/1252
CM 75
76 - Added :meth:`~pyramid.config.Configurator.set_response_factory` and the
77   ``response_factory`` keyword argument to the constructor of
78   :class:`~pyramid.config.Configurator` for defining a factory that will return
a46b07 79   a custom ``Response`` class. See https://github.com/Pylons/pyramid/pull/1499
bfe000 80
a46b07 81 - Added :attr:`pyramid.config.Configurator.root_package` attribute and init
SP 82   parameter to assist with includible packages that wish to resolve resources
83   relative to the package in which the configurator was created. This is
84   especially useful for add-ons that need to load asset specs from settings, in
85   which case it may be natural for a developer to define imports or assets
86   relative to the top-level package. See
87   https://github.com/Pylons/pyramid/pull/1337
bfe000 88
CM 89 - Overall improvments for the ``proutes`` command. Added ``--format`` and
90   ``--glob`` arguments to the command, introduced the ``method``
91   column for displaying available request methods, and improved the ``view``
a46b07 92   output by showing the module instead of just ``__repr__``. See
SP 93   https://github.com/Pylons/pyramid/pull/1488
bfe000 94
CM 95 - ``pserve`` can now take a ``-b`` or ``--browser`` option to open the server
96   URL in a web browser. See https://github.com/Pylons/pyramid/pull/1533
97
a46b07 98 - Support keyword-only arguments and function annotations in views in Python 3.
SP 99   See https://github.com/Pylons/pyramid/pull/1556
bfe000 100
CM 101 - The ``append_slash`` argument of
102   :meth:`~pyramid.config.Configurator.add_notfound_view()` will now accept
103   anything that implements the :class:`~pyramid.interfaces.IResponse` interface
104   and will use that as the response class instead of the default
a46b07 105   :class:`~pyramid.httpexceptions.HTTPFound`. See
bfe000 106   https://github.com/Pylons/pyramid/pull/1610
CM 107
108 - The :class:`~pyramid.config.Configurator` has grown the ability to allow
a46b07 109   actions to call other actions during a commit cycle. This enables much more
bfe000 110   logic to be placed into actions, such as the ability to invoke other actions
CM 111   or group them for improved conflict detection. We have also exposed and
a46b07 112   documented the configuration phases that Pyramid uses in order to further
SP 113   assist in building conforming add-ons. See
114   https://github.com/Pylons/pyramid/pull/1513
bfe000 115
CM 116 - Allow an iterator to be returned from a renderer. Previously it was only
a46b07 117   possible to return bytes or unicode. See
SP 118   https://github.com/Pylons/pyramid/pull/1417
bfe000 119
CM 120 - Improve robustness to timing attacks in the
121   :class:`~pyramid.authentication.AuthTktCookieHelper` and the
122   :class:`~pyramid.session.SignedCookieSessionFactory` classes by using the
a46b07 123   stdlib's ``hmac.compare_digest`` if it is available (such as Python 2.7.7+
SP 124   and 3.3+). See https://github.com/Pylons/pyramid/pull/1457
bfe000 125
a46b07 126 - Improve the readability of the ``pcreate`` shell script output. See
SP 127   https://github.com/Pylons/pyramid/pull/1453
bfe000 128
a46b07 129 - Make it simple to define ``notfound`` and ``forbidden`` views that wish to
SP 130   use the default exception-response view, but with altered predicates and
131   other configuration options. The ``view`` argument is now optional in
bfe000 132   :meth:`~pyramid.config.Configurator.add_notfound_view` and
CM 133   :meth:`~pyramid.config.Configurator.add_forbidden_view` See
134   https://github.com/Pylons/pyramid/issues/494
135
136 - The ``pshell`` script will now load a ``PYTHONSTARTUP`` file if one is
a46b07 137   defined in the environment prior to launching the interpreter. See
SP 138   https://github.com/Pylons/pyramid/pull/1448
bfe000 139
a46b07 140 - Add new HTTP exception objects for status codes ``428 Precondition
SP 141   Required``, ``429 Too Many Requests`` and ``431 Request Header Fields Too
142   Large`` in ``pyramid.httpexceptions``. See
143   https://github.com/Pylons/pyramid/pull/1372/files
bfe000 144
CM 145 - ``pcreate`` when run without a scaffold argument will now print information
a46b07 146   on the missing flag, as well as a list of available scaffolds. See
bfe000 147   https://github.com/Pylons/pyramid/pull/1566 and
CM 148   https://github.com/Pylons/pyramid/issues/1297
149
850f3f 150 - ``pcreate`` will now ask for confirmation if invoked with an argument for a
MM 151   project name that already exists or is importable in the current environment.
152   See https://github.com/Pylons/pyramid/issues/1357 and
153   https://github.com/Pylons/pyramid/pull/1837
154
bfe000 155 - Add :func:`pyramid.request.apply_request_extensions` function which can be
CM 156   used in testing to apply any request extensions configured via
157   ``config.add_request_method``. Previously it was only possible to test the
a46b07 158   extensions by going through Pyramid's router. See
bfe000 159   https://github.com/Pylons/pyramid/pull/1581
CM 160
161 - Make it possible to subclass ``pyramid.request.Request`` and also use
a46b07 162   ``pyramid.request.Request.add_request.method``. See
bfe000 163   https://github.com/Pylons/pyramid/issues/1529
CM 164
a46b07 165 - Additional shells for ``pshell`` can now be registered as entry points. See
850f3f 166   https://github.com/Pylons/pyramid/pull/1891 and
MM 167   https://github.com/Pylons/pyramid/pull/2012
168
169 - The variables injected into ``pshell`` are now displayed with their
a46b07 170   docstrings instead of the default ``str(obj)`` when possible. See
SP 171   https://github.com/Pylons/pyramid/pull/1929
172
850f3f 173
bfe000 174 Deprecations
CM 175 ------------
850f3f 176
a46b07 177 - The ``pserve`` command's daemonization features, as well as
SP 178   ``--monitor-restart``, have been deprecated. This includes the
179   ``[start,stop,restart,status]`` subcommands, as well as the ``--daemon``,
180   ``--stop-daemon``, ``--pid-file``, ``--status``, ``--user``, and ``--group``
181   flags. See https://github.com/Pylons/pyramid/pull/2120 and
182   https://github.com/Pylons/pyramid/pull/2189 and
183   https://github.com/Pylons/pyramid/pull/1641
850f3f 184
a46b07 185   Please use a real process manager in the future instead of relying on
SP 186   ``pserve`` to daemonize itself. Many options exist, including your operating
187   system's services, such as Systemd or Upstart, as well as Python-based
850f3f 188   solutions like Circus and Supervisor.
MM 189
a46b07 190   See https://github.com/Pylons/pyramid/pull/1641 and
SP 191   https://github.com/Pylons/pyramid/pull/2120
bfe000 192
CM 193 - The ``principal`` argument to :func:`pyramid.security.remember` was renamed
a46b07 194   to ``userid``. Using ``principal`` as the argument name still works and will
bfe000 195   continue to work for the next few releases, but a deprecation warning is
CM 196   printed.
197
198
199 Scaffolding Enhancements
200 ------------------------
201
202 - Added line numbers to the log formatters in the scaffolds to assist with
203   debugging. See https://github.com/Pylons/pyramid/pull/1326
204
a46b07 205 - Updated scaffold generating machinery to return the version of :app:`Pyramid`
SP 206   and its documentation for use in scaffolds. Updated ``starter``, ``alchemy``
207   and ``zodb`` templates to have links to correctly versioned documentation,
208   and to reflect which :app:`Pyramid` was used to generate the scaffold.
978135 209
a46b07 210 - Removed non-ASCII copyright symbol from templates, as this was causing the
SP 211   scaffolds to fail for project generation.
212
978135 213
CM 214 Documentation Enhancements
215 --------------------------
216
a46b07 217 - Removed logging configuration from Quick Tutorial ``ini`` files, except for
SP 218   scaffolding- and logging-related chapters, to avoid needing to explain it too
978135 219   early.
CM 220
a46b07 221 - Improve and clarify the documentation on what :app:`Pyramid` defines as a
SP 222   ``principal`` and a ``userid`` in its security APIs. See
223   https://github.com/Pylons/pyramid/pull/1399
850f3f 224
MM 225 - Moved the documentation for ``accept`` on
226   :meth:`pyramid.config.Configurator.add_view` to no longer be part of the
227   predicate list. See https://github.com/Pylons/pyramid/issues/1391 for a bug
228   report stating ``not_`` was failing on ``accept``. Discussion with @mcdonc
229   led to the conclusion that it should not be documented as a predicate.
a46b07 230   See https://github.com/Pylons/pyramid/pull/1487 for this PR.
850f3f 231
MM 232 - Clarify a previously-implied detail of the ``ISession.invalidate`` API
233   documentation.
a46b07 234
SP 235 - Add documentation of command line programs (``p*`` scripts). See
236   https://github.com/Pylons/pyramid/pull/2191