diff options
| author | John Anderson <sontek@gmail.com> | 2015-01-01 22:18:45 -0800 |
|---|---|---|
| committer | John Anderson <sontek@gmail.com> | 2015-01-01 22:18:45 -0800 |
| commit | 35d64fd7ff6e1caf7cf43e94039c2748fd86dfbe (patch) | |
| tree | b19a2833212cd2d877250e606c0b726fca706c21 /docs | |
| parent | 22c836ecbc6f10c4851d88017243f91e469016aa (diff) | |
| parent | 0414b7c7b2e3ea45d4dcbdf273a9e332238a0f50 (diff) | |
| download | pyramid-35d64fd7ff6e1caf7cf43e94039c2748fd86dfbe.tar.gz pyramid-35d64fd7ff6e1caf7cf43e94039c2748fd86dfbe.tar.bz2 pyramid-35d64fd7ff6e1caf7cf43e94039c2748fd86dfbe.zip | |
Merge branch 'master' of https://github.com/Pylons/pyramid into support_more_features_in_routes
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/_static/pyramid_router.png | bin | 0 -> 120643 bytes | |||
| m--------- | docs/_themes | 0 | ||||
| -rw-r--r-- | docs/glossary.rst | 4 | ||||
| -rw-r--r-- | docs/narr/hooks.rst | 47 | ||||
| -rw-r--r-- | docs/narr/router.rst | 4 |
5 files changed, 53 insertions, 2 deletions
diff --git a/docs/_static/pyramid_router.png b/docs/_static/pyramid_router.png Binary files differnew file mode 100644 index 000000000..3c9f81158 --- /dev/null +++ b/docs/_static/pyramid_router.png diff --git a/docs/_themes b/docs/_themes -Subproject 3bec9280a6cedb15e97e5899021aa8d723c2538 +Subproject b14bf8c2a0d95ae8e3d38d07ad3721370ae6f3f diff --git a/docs/glossary.rst b/docs/glossary.rst index 01300a0be..911c22075 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -16,6 +16,10 @@ Glossary An object which, provided a :term:`WSGI` environment as a single positional argument, returns a Pyramid-compatible request. + response factory + An object which, provided a :term:`request` as a single positional + argument, returns a Pyramid-compatible response. + response An object returned by a :term:`view callable` that represents response data returned to the requesting user agent. It must implement the diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index 4da36e730..e250c2d7e 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -354,6 +354,53 @@ We attach and cache an object named ``extra`` to the ``request`` object. .. _beforerender_event: +.. index:: + single: response factory + +.. _changing_the_response_factory: + +Changing the Response Factory +------------------------------- + +.. versionadded:: 1.6 + +Whenever :app:`Pyramid` returns a response from a view it creates a +:term:`response` object. By default, an instance of the +:class:`pyramid.response.Response` class is created to represent the response +object. + +The factory that :app:`Pyramid` uses to create a response object instance can be +changed by passing a ``response_factory`` argument to the constructor of the +:term:`configurator`. This argument can be either a callable or a +:term:`dotted Python name` representing a callable. + +.. code-block:: python + :linenos: + + from pyramid.response import Response + + class MyResponse(Response): + pass + + config = Configurator(response_factory=lambda r: MyResponse()) + +If you're doing imperative configuration, and you'd rather do it after you've +already constructed a :term:`configurator` it can also be registered via the +:meth:`pyramid.config.Configurator.set_response_factory` method: + +.. code-block:: python + :linenos: + + from pyramid.config import Configurator + from pyramid.response import Response + + class MyResponse(Response): + pass + + config = Configurator() + config.set_response_factory(lambda r: MyResponse()) + + Using The Before Render Event ----------------------------- diff --git a/docs/narr/router.rst b/docs/narr/router.rst index 693217a6b..6f90c70cc 100644 --- a/docs/narr/router.rst +++ b/docs/narr/router.rst @@ -9,7 +9,7 @@ Request Processing ================== -.. image:: ../_static/pyramid_request_processing.svg +.. image:: ../_static/pyramid_request_processing.* :alt: Request Processing Once a :app:`Pyramid` application is up and running, it is ready to accept @@ -119,7 +119,7 @@ request enters a :app:`Pyramid` application through to the point that #. The :term:`thread local` stack is popped. -.. image:: ../_static/pyramid_router.svg +.. image:: ../_static/pyramid_router.* :alt: Pyramid Router This is a very high-level overview that leaves out various details. For more |
