What's New in Pyramid 1.8

This article explains the new features in Pyramid version 1.8 as compared to its predecessor, Pyramid 1.7. It also documents backwards incompatibilities between the two versions and deprecations added to Pyramid 1.8, as well as software dependency changes and notable documentation additions.

Major Feature Additions

  • Added pyramid.config.Configurator.add_exception_view() and the pyramid.view.exception_view_config() decorator. It is now possible using these methods or via the new exception_only=True option to pyramid.config.Configurator.add_view() to add a view which will only be matched when handling an exception. Previously, any exception views were also registered for a traversal context that inherited from the exception class which prevented any exception-only optimizations. See https://github.com/Pylons/pyramid/pull/2660

  • pserve --reload now uses the hupper library to monitor file changes. This comes with many improvements:

    • If the watchdog package is installed then monitoring will be done using inotify instead of cpu and disk-intensive polling.

    • The monitor is now a separate process that will not crash and starts up before any of your code.

    • The monitor will not restart the process after a crash until a file is saved.

    • The monitor works on windows.

    • You can now trigger a reload manually from a pyramid view or any other code via hupper.get_reloader().trigger_reload(). Kind of neat.

    • You can trigger a reload by issuing a SIGHUP to the monitor process.

    See https://github.com/Pylons/pyramid/pull/2805

Minor Feature Additions

Backwards Incompatibilities

  • Following the Pyramid deprecation period (1.6 -> 1.8), daemon support for pserve has been removed. This includes removing the daemon commands (start, stop, restart, status) as well as the following arguments: --daemon, --pid-file, --log-file, --monitor-restart, --status, --user, --group, --stop-daemon

    To run your server as a daemon you should use a process manager instead of pserve.

    See https://github.com/Pylons/pyramid/pull/2615

  • Change static view to avoid setting the Content-Encoding response header to an encoding guessed using Python's mimetypes module. This was causing clients to decode the content of gzipped files when downloading them. The client would end up with a foo.txt.gz file on disk that was already decoded, thus should really be foo.txt. Also, the Content-Encoding should only have been used if the client itself broadcast support for the encoding via Accept-Encoding request headers. See https://github.com/Pylons/pyramid/pull/2810

  • pcreate is now interactive by default. You will be prompted if a file already exists with different content. Previously if there were similar files it would silently skip them unless you specified --interactive or --overwrite. See https://github.com/Pylons/pyramid/pull/2775

  • Support for the IContextURL interface that was deprecated in Pyramid 1.3 has been removed. See https://github.com/Pylons/pyramid/pull/2822

  • Settings are no longer accessible as attributes on the settings object (e.g. request.registry.settings.foo). This was deprecated in Pyramid 1.2. See https://github.com/Pylons/pyramid/pull/2823

  • Removed undocumented argument cachebust_match from pyramid.static.static_view. This argument was shipped accidentally in Pyramid 1.6. See https://github.com/Pylons/pyramid/pull/2681

Deprecations

  • The pcreate script and the core scaffolds (starter, alchemy and zodb) have been deprecated.

    They have been replaced with the decision to embrace the popular cookiecutter project as a best-of-breed project templating solution.

    pcreate was originally introduced when very few alternatives existed that supported Python 3. Fortunately the situation has improved and with possible tooling support for cookiecutters being discussed by major IDEs, and the simplicity of the jinja2 syntax, it is exciting to embrace the project moving forward!

    All of Pyramid's official scaffolds as well as the tutorials have been ported to cookiecutters:

    See https://github.com/Pylons/pyramid/pull/2780

Documentation Enhancements