summaryrefslogtreecommitdiff
path: root/docs/narr
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-07-28 16:56:20 -0400
committerChris McDonough <chrism@plope.com>2011-07-28 16:56:20 -0400
commitbe631daa6812a004cdf52353cfca2bd6255f7135 (patch)
tree15fb46334e15940ebdf40b4a16ddb93c821f133d /docs/narr
parentd8d14a474ac84a58d3545768fecd3fe1c78219c0 (diff)
parent1d38fdf1d58af73f224f4c92dbbc90fb1803ca64 (diff)
downloadpyramid-be631daa6812a004cdf52353cfca2bd6255f7135.tar.gz
pyramid-be631daa6812a004cdf52353cfca2bd6255f7135.tar.bz2
pyramid-be631daa6812a004cdf52353cfca2bd6255f7135.zip
merge
Diffstat (limited to 'docs/narr')
-rw-r--r--docs/narr/hooks.rst17
1 files changed, 16 insertions, 1 deletions
diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst
index 985934736..df081d35c 100644
--- a/docs/narr/hooks.rst
+++ b/docs/narr/hooks.rst
@@ -537,7 +537,8 @@ Changing How Pyramid Treats View Responses
It is possible to control how Pyramid treats the result of calling a view
callable on a per-type basis by using a hook involving
-:meth:`pyramid.config.Configurator.add_response_adapter`.
+:meth:`pyramid.config.Configurator.add_response_adapter` or the
+:class:`~pyramid.response.response_adapter` decorator.
.. note:: This feature is new as of Pyramid 1.1.
@@ -574,6 +575,20 @@ 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: