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