diff options
| author | Chris McDonough <chrism@plope.com> | 2011-07-28 17:06:29 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-07-28 17:06:29 -0400 |
| commit | 1f901ab75c55bafc9c233c3c9588cc1bd92d9d66 (patch) | |
| tree | eb91a101debb0ec0500d53aa9dbc12bf816c4ce9 /docs | |
| parent | 7fe7cccc067ab96b7c3d72a4e84813be15c63d5a (diff) | |
| download | pyramid-1f901ab75c55bafc9c233c3c9588cc1bd92d9d66.tar.gz pyramid-1f901ab75c55bafc9c233c3c9588cc1bd92d9d66.tar.bz2 pyramid-1f901ab75c55bafc9c233c3c9588cc1bd92d9d66.zip | |
add some edits to the docs for response_adapter decorator; fix renderings
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/glossary.rst | 5 | ||||
| -rw-r--r-- | docs/narr/hooks.rst | 37 |
2 files changed, 28 insertions, 14 deletions
diff --git a/docs/glossary.rst b/docs/glossary.rst index cc1d6201d..c6705fdc5 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -23,6 +23,11 @@ Glossary a subclass such as :class:`pyramid.httpexceptions.HTTPFound`. See :ref:`webob_chapter` for information about response objects. + response adapter + A callable which accepts an arbitrary object and "converts" it to a + :class:`pyramid.response.Response` object. See :ref:`using_iresponse` + for more information. + Repoze "Repoze" is essentially a "brand" of software developed by `Agendaless Consulting <http://agendaless.com>`_ and a set of contributors. The diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index df081d35c..fc3f01271 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -575,20 +575,6 @@ Response: config.add_response_adapter(string_response_adapter, str) -The above example using the :class:`~pyramid.response.response_adapter` -decorator: - -.. code-block:: python - :linenos: - - from pyramid.response import Response - from pyramid.response import response_adapter - - @response_adapter(str) - def string_response_adapter(s): - response = Response(s) - return response - Likewise, if you want to be able to return a simplified kind of response object from view callables, you can use the IResponse hook to register an adapter to the more complex IResponse interface: @@ -639,6 +625,29 @@ startup time, as by their nature, instances of this class (and instances of subclasses of the class) will natively provide IResponse. The adapter registered for ``webob.Response`` simply returns the response object. +Instead of using :meth:`pyramid.config.Configurator.add_response_adapter`, +you can use the :class:`pyramid.response.response_adapter` decorator: + +.. code-block:: python + :linenos: + + from pyramid.response import Response + from pyramid.response import response_adapter + + @response_adapter(str) + def string_response_adapter(s): + response = Response(s) + return response + +The above example, when scanned, has the same effect as: + +.. code-block:: python + + config.add_response_adapter(string_response_adapter, str) + +The :class:`~pyramid.response.response_adapter` decorator will have no effect +until activated by a :term:`scan`. + .. index:: single: view mapper |
