Michael Merickel
2017-07-14 29615272e0f5668373f5e1eca56d3209cfac8ffa
commit | author | age
75a92c 1 What's New in Pyramid 1.8
MM 2 =========================
3
4 This article explains the new features in :app:`Pyramid` version 1.8 as
5 compared to its predecessor, :app:`Pyramid` 1.7. It also documents backwards
6 incompatibilities between the two versions and deprecations added to
7 :app:`Pyramid` 1.8, as well as software dependency changes and notable
8 documentation additions.
9
d2a84a 10 Bug Fix Releases
MM 11 ----------------
12
13 Pyramid 1.8 was released on 2017-01-21.
14
15 The following bug fix releases were made since then. Bug fix releases also
16 include documentation improvements and other minor feature changes.
17
18 - :ref:`changes_1.8.1`
be41b0 19 - :ref:`changes_1.8.2`
789d74 20 - :ref:`changes_1.8.3`
ab4cc1 21 - :ref:`changes_1.8.4`
296152 22 - :ref:`changes_1.8.5`
d2a84a 23
c22270 24 Major Feature Additions
MM 25 -----------------------
75a92c 26
MM 27 - Added :meth:`pyramid.config.Configurator.add_exception_view` and the
28   :func:`pyramid.view.exception_view_config` decorator. It is now possible
29   using these methods or via the new ``exception_only=True`` option to
30   :meth:`pyramid.config.Configurator.add_view` to add a view which will only
31   be matched when handling an exception. Previously, any exception views were
32   also registered for a traversal context that inherited from the exception
33   class which prevented any exception-only optimizations.
34   See https://github.com/Pylons/pyramid/pull/2660
35
36 - ``pserve --reload`` now uses the
1c561a 37   `hupper <https://docs.pylonsproject.org/projects/hupper/en/latest/>`_
75a92c 38   library to monitor file changes. This comes with many improvements:
MM 39
40   - If the `watchdog <http://pythonhosted.org/watchdog/>`_ package is
41     installed then monitoring will be done using inotify instead of
42     cpu and disk-intensive polling.
43
44   - The monitor is now a separate process that will not crash and starts up
45     before any of your code.
46
47   - The monitor will not restart the process after a crash until a file is
48     saved.
49
50   - The monitor works on windows.
51
52   - You can now trigger a reload manually from a pyramid view or any other
53     code via ``hupper.get_reloader().trigger_reload()``. Kind of neat.
54
55   - You can trigger a reload by issuing a ``SIGHUP`` to the monitor process.
56
57   See https://github.com/Pylons/pyramid/pull/2805
58
c22270 59 Minor Feature Additions
MM 60 -----------------------
61
62 - Python 3.6 compatibility.
63   https://github.com/Pylons/pyramid/issues/2835
64
65 - The ``_get_credentials`` private method of
66   :class:`pyramid.authentication.BasicAuthAuthenticationPolicy`
67   has been extracted into standalone function
68   :func:`pyramid.authentication.extract_http_basic_credentials`, this function
69   extracts HTTP Basic credentials from a ``request`` object, and returns them
70   as a named tuple. See https://github.com/Pylons/pyramid/pull/2662
71
72 - Pyramid 1.4 silently dropped a feature of the configurator that has been
73   restored. It's again possible for action discriminators to conflict across
74   different action orders.
75   See https://github.com/Pylons/pyramid/pull/2757
76
77 - :func:`pyramid.paster.bootstrap` and its sibling
78   :func:`pyramid.scripting.prepare` can now be used as context managers to
79   automatically invoke the ``closer`` and pop threadlocals off of the stack
80   to prevent memory leaks. See https://github.com/Pylons/pyramid/pull/2760
81
82 - Added the ``exception_only`` boolean to
83   :class:`pyramid.interfaces.IViewDeriverInfo` which can be used by view
84   derivers to determine if they are wrapping a view which only handles
85   exceptions. This means that it is no longer necessary to perform request-time
86   checks for ``request.exception`` to determine if the view is handling an
87   exception - the pipeline can be optimized at config-time.
88   See https://github.com/Pylons/pyramid/pull/2660
89
e82f3d 90 - ``pcreate`` learned about ``--package-name`` to allow you to create a new
MM 91   project in an existing folder with a different package name than the project
92   name. See https://github.com/Pylons/pyramid/pull/2783
93
c22270 94 - ``pserve`` should now work with ``gevent`` and other workers that need
MM 95   to monkeypatch the process, assuming the server and / or the app do so
96   as soon as possible before importing the rest of pyramid.
97   See https://github.com/Pylons/pyramid/pull/2797
98
99 - Pyramid no longer copies the settings object passed to the
100   ``pyramid.config.Configurator(settings=)``. The original ``dict`` is kept.
101   See https://github.com/Pylons/pyramid/pull/2823
102
103 - The csrf trusted origins setting may now be a whitespace-separated list of
104   domains. Previously only a python list was allowed. Also, it can now be set
105   using the ``PYRAMID_CSRF_TRUSTED_ORIGINS`` environment variable similar to
106   other settings. See https://github.com/Pylons/pyramid/pull/2823
107
75a92c 108 - A new ``[pserve]`` section is supported in your config files with a
MM 109   ``watch_files`` key that can configure ``pserve --reload`` to monitor custom
110   file paths. See https://github.com/Pylons/pyramid/pull/2827
111
112 - Allow streaming responses to be made from subclasses of
113   :class:`pyramid.httpexceptions.HTTPException`. Previously the response would
114   be unrolled while testing for a body, making it impossible to stream
115   a response.
116   See https://github.com/Pylons/pyramid/pull/2863
117
118 - Update starter, alchemy and zodb scaffolds to support IPv6 by using the
119   new ``listen`` directives in waitress.
120   See https://github.com/Pylons/pyramid/pull/2853
121
122 - All p* scripts now use argparse instead of optparse. This improves their
123   ``--help`` output as well as enabling nicer documentation of their options.
124   See https://github.com/Pylons/pyramid/pull/2864
125
1eaf3d 126 - Added an ``override`` option to
eefe76 127   :meth:`pyramid.config.Configurator.add_translation_dirs` to allow
bf700d 128   later calls to place translation directories at a higher priority then
MM 129   earlier calls. See https://github.com/Pylons/pyramid/pull/2902
130
1b8a0c 131 - Added a new ``callback`` option to
MM 132   :meth:`pyramid.config.Configurator.set_default_csrf_options`` which
133   can be used to determine per-request whether CSRF checking should be enabled
134   to allow for a mix authentication methods. Only cookie-based methods
135   generally require CSRF checking.
136   See https://github.com/Pylons/pyramid/pull/2778
137
c22270 138 Backwards Incompatibilities
MM 139 ---------------------------
140
141 - Following the Pyramid deprecation period (1.6 -> 1.8),
142   daemon support for pserve has been removed. This includes removing the
143   daemon commands (start, stop, restart, status) as well as the following
144   arguments: ``--daemon``, ``--pid-file``, ``--log-file``,
145   ``--monitor-restart``, ``--status``, ``--user``, ``--group``,
146   ``--stop-daemon``
147
148   To run your server as a daemon you should use a process manager instead of
149   pserve.
150
151   See https://github.com/Pylons/pyramid/pull/2615
152
153 - Change static view to avoid setting the ``Content-Encoding`` response header
154   to an encoding guessed using Python's ``mimetypes`` module. This was causing
155   clients to decode the content of gzipped files when downloading them. The
156   client would end up with a ``foo.txt.gz`` file on disk that was already
157   decoded, thus should really be ``foo.txt``. Also, the ``Content-Encoding``
158   should only have been used if the client itself broadcast support for the
159   encoding via ``Accept-Encoding`` request headers.
160   See https://github.com/Pylons/pyramid/pull/2810
161
162 - ``pcreate`` is now interactive by default. You will be prompted if a file
163   already exists with different content. Previously if there were similar
164   files it would silently skip them unless you specified ``--interactive``
165   or ``--overwrite``.
166   See https://github.com/Pylons/pyramid/pull/2775
167
168 - Support for the ``IContextURL`` interface that was deprecated in Pyramid 1.3
169   has been removed.  See https://github.com/Pylons/pyramid/pull/2822
170
171 - Settings are no longer accessible as attributes on the settings object
172   (e.g. ``request.registry.settings.foo``). This was deprecated in Pyramid 1.2.
173   See https://github.com/Pylons/pyramid/pull/2823
174
175 - Removed undocumented argument ``cachebust_match`` from
176   ``pyramid.static.static_view``. This argument was shipped accidentally
177   in Pyramid 1.6. See https://github.com/Pylons/pyramid/pull/2681
178
75a92c 179 Deprecations
MM 180 ------------
181
8553bd 182 - The ``pcreate`` script and the core scaffolds (``starter``, ``alchemy`` and
MM 183   ``zodb``) have been deprecated.
184
185   They have been replaced with the decision to embrace the popular
186   `cookiecutter <https://cookiecutter.readthedocs.io/en/latest/>`_ project
187   as a best-of-breed project templating solution.
188
189   ``pcreate`` was originally introduced when very few alternatives existed
190   that supported Python 3. Fortunately the situation has improved and
191   with possible tooling support for cookiecutters being discussed by major
192   IDEs, and the simplicity of the jinja2 syntax, it is exciting to embrace
193   the project moving forward!
75a92c 194
6e037c 195   All of Pyramid's official scaffolds as well as the tutorials have been
MM 196   ported to cookiecutters:
75a92c 197
6e037c 198   - `pyramid-cookiecutter-starter
MM 199     <https://github.com/Pylons/pyramid-cookiecutter-starter>`_
200
201   - `pyramid-cookiecutter-alchemy
202     <https://github.com/Pylons/pyramid-cookiecutter-alchemy>`_
203
204   - `pyramid-cookiecutter-zodb
205     <https://github.com/Pylons/pyramid-cookiecutter-zodb>`_
206
207   See https://github.com/Pylons/pyramid/pull/2780
75a92c 208
MM 209 Documentation Enhancements
210 --------------------------
211
85b301 212 - Update Typographical Conventions.
75a92c 213   https://github.com/Pylons/pyramid/pull/2838
MM 214
215 - Add `pyramid_nacl_session
1c561a 216   <https://docs.pylonsproject.org/projects/pyramid-nacl-session/en/latest/>`_
75a92c 217   to session factories. See https://github.com/Pylons/pyramid/issues/2791
MM 218
219 - Update HACKING.txt from stale branch that was never merged to master.
220   See https://github.com/Pylons/pyramid/pull/2782
221
222 - Updated Windows installation instructions and related bits.
223   See https://github.com/Pylons/pyramid/issues/2661
224
225 - Fix an inconsistency in the documentation between view predicates and
226   route predicates and highlight the differences in their APIs.
227   See https://github.com/Pylons/pyramid/pull/2764
228
229 - Clarify a possible misuse of the ``headers`` kwarg to subclasses of
230   :class:`pyramid.httpexceptions.HTTPException` in which more appropriate
231   kwargs from the parent class :class:`pyramid.response.Response` should be
232   used instead. See https://github.com/Pylons/pyramid/pull/2750
6e037c 233
MM 234 - The SQLAlchemy + URL Dispatch + Jinja2 (``wiki2``) and
235   ZODB + Traversal + Chameleon (``wiki``) tutorials have been updated to
236   utilize the new cookiecutters and drop support for the ``pcreate``
237   scaffolds.
238
239   See https://github.com/Pylons/pyramid/pull/2881 and
240   https://github.com/Pylons/pyramid/pull/2883.
fca6c1 241
SP 242 - Quick Tour, Quick Tutorial, and most files throughout the documentation have
243   been updated to use cookiecutters instead of pcreate and scaffolds.
244   See https://github.com/Pylons/pyramid/pull/2888 and
245   https://github.com/Pylons/pyramid/pull/2889
776666 246
MM 247 - Updated the ``mod_wsgi`` tutorial to use cookiecutters and Apache 2.4+.
248   See https://github.com/Pylons/pyramid/pull/2901