diff options
| -rw-r--r-- | CHANGES.txt | 37 | ||||
| -rw-r--r-- | docs/api/config.rst | 1 | ||||
| -rw-r--r-- | docs/api/view.rst | 2 | ||||
| -rw-r--r-- | docs/whatsnew-1.8.rst | 179 | ||||
| -rw-r--r-- | pyramid/scripts/pcreate.py | 7 | ||||
| -rw-r--r-- | pyramid/scripts/prequest.py | 3 | ||||
| -rw-r--r-- | pyramid/scripts/proutes.py | 3 | ||||
| -rw-r--r-- | pyramid/scripts/pserve.py | 3 | ||||
| -rw-r--r-- | pyramid/scripts/pshell.py | 3 | ||||
| -rw-r--r-- | pyramid/scripts/ptweens.py | 1 | ||||
| -rw-r--r-- | pyramid/scripts/pviews.py | 3 | ||||
| -rw-r--r-- | pyramid/tests/test_testing.py | 51 | ||||
| -rw-r--r-- | setup.py | 5 |
13 files changed, 171 insertions, 127 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index ac329f574..55e56ff1a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -48,9 +48,9 @@ Features - Python 3.6 compatibility. https://github.com/Pylons/pyramid/issues/2835 -- pcreate learned about ``--package-name`` to allow you to create a new project - in an existing folder with a different package name than the project name. - See https://github.com/Pylons/pyramid/pull/2783 +- ``pcreate`` learned about ``--package-name`` to allow you to create a new + project in an existing folder with a different package name than the project + name. See https://github.com/Pylons/pyramid/pull/2783 - The ``_get_credentials`` private method of ``BasicAuthAuthenticationPolicy`` has been extracted into standalone function ``extract_http_basic_credentials`` @@ -205,10 +205,28 @@ Bug Fixes Deprecations ------------ +- The ``pcreate`` script and related scaffolds have been deprecated in favor + of the popular + `cookiecutter <https://cookiecutter.readthedocs.io/en/latest/>`_ project. + + All of Pyramid's official scaffolds as well as the tutorials have been + ported to cookiecutters: + + - `pyramid-cookiecutter-starter + <https://github.com/Pylons/pyramid-cookiecutter-starter>`_ + + - `pyramid-cookiecutter-alchemy + <https://github.com/Pylons/pyramid-cookiecutter-alchemy>`_ + + - `pyramid-cookiecutter-zodb + <https://github.com/Pylons/pyramid-cookiecutter-zodb>`_ + + See https://github.com/Pylons/pyramid/pull/2780 + Documentation Changes --------------------- -- Update Typographical Conventions and add a Style Guide. +- Update Typographical Conventions. https://github.com/Pylons/pyramid/pull/2838 - Add `pyramid_nacl_session @@ -229,3 +247,14 @@ Documentation Changes :class:`pyramid.httpexceptions.HTTPException` in which more appropriate kwargs from the parent class :class:`pyramid.response.Response` should be used instead. See https://github.com/Pylons/pyramid/pull/2750 + +- The SQLAlchemy + URL Dispatch + Jinja2 (``wiki2``) and + ZODB + Traversal + Chameleon (``wiki``) tutorials have been updated to + utilize the new cookiecutters and drop support for the ``pcreate`` + scaffolds. + + See https://github.com/Pylons/pyramid/pull/2881 and + https://github.com/Pylons/pyramid/pull/2883. + +- Improve output of p* script descriptions for help. + See https://github.com/Pylons/pyramid/pull/2886
\ No newline at end of file diff --git a/docs/api/config.rst b/docs/api/config.rst index ab3ff0fe1..62f138b76 100644 --- a/docs/api/config.rst +++ b/docs/api/config.rst @@ -26,6 +26,7 @@ .. automethod:: add_view .. automethod:: add_notfound_view .. automethod:: add_forbidden_view + .. automethod:: add_exception_view :methodcategory:`Adding an Event Subscriber` diff --git a/docs/api/view.rst b/docs/api/view.rst index d8e429552..e41212012 100644 --- a/docs/api/view.rst +++ b/docs/api/view.rst @@ -23,4 +23,6 @@ .. autoclass:: forbidden_view_config :members: + .. autoclass:: exception_view_config + :members: diff --git a/docs/whatsnew-1.8.rst b/docs/whatsnew-1.8.rst index 20261e704..e666f0cd1 100644 --- a/docs/whatsnew-1.8.rst +++ b/docs/whatsnew-1.8.rst @@ -7,57 +7,47 @@ incompatibilities between the two versions and deprecations added to :app:`Pyramid` 1.8, as well as software dependency changes and notable documentation additions. -Backwards Incompatibilities ---------------------------- +Major Feature Additions +----------------------- -- 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`` +- Added :meth:`pyramid.config.Configurator.add_exception_view` and the + :func:`pyramid.view.exception_view_config` decorator. It is now possible + using these methods or via the new ``exception_only=True`` option to + :meth:`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 - To run your server as a daemon you should use a process manager instead of - pserve. +- ``pserve --reload`` now uses the + `hupper <http://docs.pylonsproject.org/projects/hupper/en/latest/>`_ + library to monitor file changes. This comes with many improvements: - See https://github.com/Pylons/pyramid/pull/2615 + - If the `watchdog <http://pythonhosted.org/watchdog/>`_ package is + installed then monitoring will be done using inotify instead of + cpu and disk-intensive polling. -- 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 + - The monitor is now a separate process that will not crash and starts up + before any of your code. -- ``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 + - The monitor will not restart the process after a crash until a file is + saved. -- Support for the ``IContextURL`` interface that was deprecated in Pyramid 1.3 - has been removed. See https://github.com/Pylons/pyramid/pull/2822 + - The monitor works on windows. -- 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 + - You can now trigger a reload manually from a pyramid view or any other + code via ``hupper.get_reloader().trigger_reload()``. Kind of neat. -- 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 + - You can trigger a reload by issuing a ``SIGHUP`` to the monitor process. -Feature Additions ------------------ + See https://github.com/Pylons/pyramid/pull/2805 + +Minor Feature Additions +----------------------- - Python 3.6 compatibility. https://github.com/Pylons/pyramid/issues/2835 -- ``pcreate`` learned about --package-name to allow you to create a new project - in an existing folder with a different package name than the project name. - See https://github.com/Pylons/pyramid/pull/2783 - - The ``_get_credentials`` private method of :class:`pyramid.authentication.BasicAuthAuthenticationPolicy` has been extracted into standalone function @@ -75,15 +65,6 @@ Feature Additions automatically invoke the ``closer`` and pop threadlocals off of the stack to prevent memory leaks. See https://github.com/Pylons/pyramid/pull/2760 -- Added :meth:`pyramid.config.Configurator.add_exception_view` and the - :func:`pyramid.view.exception_view_config` decorator. It is now possible - using these methods or via the new ``exception_only=True`` option to - :meth:`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 - - Added the ``exception_only`` boolean to :class:`pyramid.interfaces.IViewDeriverInfo` which can be used by view derivers to determine if they are wrapping a view which only handles @@ -106,29 +87,6 @@ Feature Additions using the ``PYRAMID_CSRF_TRUSTED_ORIGINS`` environment variable similar to other settings. See https://github.com/Pylons/pyramid/pull/2823 -- ``pserve --reload`` now uses the - `hupper <http://docs.pylonsproject.org/projects/hupper/en/latest/>` - library to monitor file changes. This comes with many improvements: - - - If the `watchdog <http://pythonhosted.org/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 - - A new ``[pserve]`` section is supported in your config files with a ``watch_files`` key that can configure ``pserve --reload`` to monitor custom file paths. See https://github.com/Pylons/pyramid/pull/2827 @@ -147,18 +105,85 @@ Feature Additions ``--help`` output as well as enabling nicer documentation of their options. See https://github.com/Pylons/pyramid/pull/2864 +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`` learned about ``--package-name`` to allow you to create a new + project in an existing folder with a different package name than the project + name. See https://github.com/Pylons/pyramid/pull/2783 + +- ``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 <https://cookiecutter.readthedocs.io/en/latest/>`_ 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: -Scaffolding Enhancements ------------------------- + - `pyramid-cookiecutter-starter + <https://github.com/Pylons/pyramid-cookiecutter-starter>`_ + - `pyramid-cookiecutter-alchemy + <https://github.com/Pylons/pyramid-cookiecutter-alchemy>`_ + + - `pyramid-cookiecutter-zodb + <https://github.com/Pylons/pyramid-cookiecutter-zodb>`_ + + See https://github.com/Pylons/pyramid/pull/2780 Documentation Enhancements -------------------------- -- Update Typographical Conventions and add a Style Guide. +- Update Typographical Conventions. https://github.com/Pylons/pyramid/pull/2838 - Add `pyramid_nacl_session @@ -179,3 +204,11 @@ Documentation Enhancements :class:`pyramid.httpexceptions.HTTPException` in which more appropriate kwargs from the parent class :class:`pyramid.response.Response` should be used instead. See https://github.com/Pylons/pyramid/pull/2750 + +- The SQLAlchemy + URL Dispatch + Jinja2 (``wiki2``) and + ZODB + Traversal + Chameleon (``wiki``) tutorials have been updated to + utilize the new cookiecutters and drop support for the ``pcreate`` + scaffolds. + + See https://github.com/Pylons/pyramid/pull/2881 and + https://github.com/Pylons/pyramid/pull/2883. diff --git a/pyramid/scripts/pcreate.py b/pyramid/scripts/pcreate.py index 75e3b1fdc..a6db520ce 100644 --- a/pyramid/scripts/pcreate.py +++ b/pyramid/scripts/pcreate.py @@ -23,13 +23,16 @@ def main(argv=sys.argv, quiet=False): class PCreateCommand(object): verbosity = 1 # required - parser = argparse.ArgumentParser(description="""\ + parser = argparse.ArgumentParser( + description="""\ Render Pyramid scaffolding to an output directory. Note: As of Pyramid 1.8, this command is deprecated. Use a specific cookiecutter instead: https://github.com/Pylons/?q=cookiecutter -""") +""", + formatter_class=argparse.RawDescriptionHelpFormatter, + ) parser.add_argument('-s', '--scaffold', dest='scaffold_name', action='append', diff --git a/pyramid/scripts/prequest.py b/pyramid/scripts/prequest.py index aefb4e18d..66feff624 100644 --- a/pyramid/scripts/prequest.py +++ b/pyramid/scripts/prequest.py @@ -47,7 +47,8 @@ class PRequestCommand(object): """ parser = argparse.ArgumentParser( - description=textwrap.dedent(description) + description=textwrap.dedent(description), + formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument( '-n', '--app-name', diff --git a/pyramid/scripts/proutes.py b/pyramid/scripts/proutes.py index 2a999e04f..80c8238a2 100644 --- a/pyramid/scripts/proutes.py +++ b/pyramid/scripts/proutes.py @@ -249,7 +249,8 @@ class PRoutesCommand(object): stdout = sys.stdout ConfigParser = configparser.ConfigParser # testing parser = argparse.ArgumentParser( - description=textwrap.dedent(description) + description=textwrap.dedent(description), + formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument('-g', '--glob', action='store', diff --git a/pyramid/scripts/pserve.py b/pyramid/scripts/pserve.py index 845933c27..e2d97f5ec 100644 --- a/pyramid/scripts/pserve.py +++ b/pyramid/scripts/pserve.py @@ -51,7 +51,8 @@ class PServeCommand(object): default_verbosity = 1 parser = argparse.ArgumentParser( - description=textwrap.dedent(description) + description=textwrap.dedent(description), + formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument( '-n', '--app-name', diff --git a/pyramid/scripts/pshell.py b/pyramid/scripts/pshell.py index d8abf6619..83e640c32 100644 --- a/pyramid/scripts/pshell.py +++ b/pyramid/scripts/pshell.py @@ -45,7 +45,8 @@ class PShellCommand(object): pkg_resources = pkg_resources # for testing parser = argparse.ArgumentParser( - description=textwrap.dedent(description) + description=textwrap.dedent(description), + formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument('-p', '--python-shell', action='store', diff --git a/pyramid/scripts/ptweens.py b/pyramid/scripts/ptweens.py index f278a0370..5ca77e52a 100644 --- a/pyramid/scripts/ptweens.py +++ b/pyramid/scripts/ptweens.py @@ -29,6 +29,7 @@ class PTweensCommand(object): """ parser = argparse.ArgumentParser( description=textwrap.dedent(description), + formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument('config_uri', diff --git a/pyramid/scripts/pviews.py b/pyramid/scripts/pviews.py index 64408bdad..4d3312917 100644 --- a/pyramid/scripts/pviews.py +++ b/pyramid/scripts/pviews.py @@ -28,7 +28,8 @@ class PViewsCommand(object): stdout = sys.stdout parser = argparse.ArgumentParser( - description=textwrap.dedent(description) + description=textwrap.dedent(description), + formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument('config_uri', diff --git a/pyramid/tests/test_testing.py b/pyramid/tests/test_testing.py index 113f7e5f4..0b4619de4 100644 --- a/pyramid/tests/test_testing.py +++ b/pyramid/tests/test_testing.py @@ -1,4 +1,5 @@ import unittest +from zope.component import getSiteManager class TestDummyRootFactory(unittest.TestCase): def _makeOne(self, environ): @@ -320,22 +321,11 @@ class Test_setUp(unittest.TestCase): def tearDown(self): from pyramid.threadlocal import manager manager.clear() - getSiteManager = self._getSM() - if getSiteManager is not None: - getSiteManager.reset() - - def _getSM(self): - try: - from zope.component import getSiteManager - except ImportError: # pragma: no cover - getSiteManager = None - return getSiteManager + getSiteManager.reset() def _assertSMHook(self, hook): - getSiteManager = self._getSM() - if getSiteManager is not None: - result = getSiteManager.sethook(None) - self.assertEqual(result, hook) + result = getSiteManager.sethook(None) + self.assertEqual(result, hook) def test_it_defaults(self): from pyramid.threadlocal import manager @@ -375,10 +365,8 @@ class Test_setUp(unittest.TestCase): from pyramid.registry import Registry registry = Registry() self._callFUT(registry=registry, hook_zca=False) - getSiteManager = self._getSM() - if getSiteManager is not None: - sm = getSiteManager() - self.assertFalse(sm is registry) + sm = getSiteManager() + self.assertFalse(sm is registry) def test_it_with_settings_passed_explicit_registry(self): from pyramid.registry import Registry @@ -403,27 +391,14 @@ class Test_tearDown(unittest.TestCase): def tearDown(self): from pyramid.threadlocal import manager manager.clear() - getSiteManager = self._getSM() - if getSiteManager is not None: - getSiteManager.reset() - - def _getSM(self): - try: - from zope.component import getSiteManager - except ImportError: # pragma: no cover - getSiteManager = None - return getSiteManager + getSiteManager.reset() def _assertSMHook(self, hook): - getSiteManager = self._getSM() - if getSiteManager is not None: - result = getSiteManager.sethook(None) - self.assertEqual(result, hook) + result = getSiteManager.sethook(None) + self.assertEqual(result, hook) def _setSMHook(self, hook): - getSiteManager = self._getSM() - if getSiteManager is not None: - getSiteManager.sethook(hook) + getSiteManager.sethook(hook) def test_defaults(self): from pyramid.threadlocal import manager @@ -438,10 +413,8 @@ class Test_tearDown(unittest.TestCase): self.assertNotEqual(current, old) self.assertEqual(registry.inited, 2) finally: - getSiteManager = self._getSM() - if getSiteManager is not None: - result = getSiteManager.sethook(None) - self.assertNotEqual(result, hook) + result = getSiteManager.sethook(None) + self.assertNotEqual(result, hook) def test_registry_cannot_be_inited(self): from pyramid.threadlocal import manager @@ -20,8 +20,6 @@ from setuptools import setup, find_packages py_version = sys.version_info[:2] -PY2 = py_version[0] == 2 - if (3, 0) <= py_version < (3, 4): warnings.warn( 'On Python 3, Pyramid only supports Python 3.4 or better', @@ -53,10 +51,9 @@ install_requires = [ tests_require = [ 'WebTest >= 1.3.1', # py3 compat + 'zope.component >= 4.0', # py3 compat ] -if PY2: - tests_require.append('zope.component>=3.11.0') docs_extras = [ 'Sphinx >= 1.3.5', |
