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