summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-06-14 02:36:07 -0400
committerChris McDonough <chrism@plope.com>2011-06-14 02:36:07 -0400
commit1a6fc7062f803b9f15b7677db9a9257a4f00bfcb (patch)
tree47048dadf66f6aad3c6ef9ef9752c11d9338e827 /docs
parent3f4f67e76c2e1338377babd983e4071f52235132 (diff)
downloadpyramid-1a6fc7062f803b9f15b7677db9a9257a4f00bfcb.tar.gz
pyramid-1a6fc7062f803b9f15b7677db9a9257a4f00bfcb.tar.bz2
pyramid-1a6fc7062f803b9f15b7677db9a9257a4f00bfcb.zip
- Added new add_response_adapter method to Configurator.
- Fix Configurator docstring wrt exception responses. - Speed up registry.queryAdapterOrSelf
Diffstat (limited to 'docs')
-rw-r--r--docs/api/config.rst2
-rw-r--r--docs/narr/hooks.rst13
2 files changed, 6 insertions, 9 deletions
diff --git a/docs/api/config.rst b/docs/api/config.rst
index 2b9d7bcef..274ee0292 100644
--- a/docs/api/config.rst
+++ b/docs/api/config.rst
@@ -40,6 +40,8 @@
.. automethod:: add_renderer(name, factory)
+ .. automethod:: add_response_adapter
+
.. automethod:: add_route
.. automethod:: add_static_view(name, path, cache_max_age=3600, permission='__no_permission_required__')
diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst
index 0db8ce5e0..8e5b93ed4 100644
--- a/docs/narr/hooks.rst
+++ b/docs/narr/hooks.rst
@@ -532,7 +532,7 @@ 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
-:class:`pyramid.interfaces.IResponse`.
+:method:`pyramid.config.Configurator.add_response_adapter`.
.. note:: This feature is new as of Pyramid 1.1.
@@ -559,7 +559,6 @@ Response:
.. code-block:: python
:linenos:
- from pyramid.interfaces import IResponse
from pyramid.response import Response
def string_response_adapter(s):
@@ -568,8 +567,7 @@ Response:
# config is an instance of pyramid.config.Configurator
- config.registry.registerAdapter(string_response_adapter, (str,),
- IResponse)
+ config.add_response_adapter(string_response_adapter, str)
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
@@ -578,7 +576,6 @@ adapter to the more complex IResponse interface:
.. code-block:: python
:linenos:
- from pyramid.interfaces import IResponse
from pyramid.response import Response
class SimpleResponse(object):
@@ -591,14 +588,12 @@ adapter to the more complex IResponse interface:
# config is an instance of pyramid.config.Configurator
- config.registry.registerAdapter(simple_response_adapter,
- (SimpleResponse,),
- IResponse)
+ config.add_response_adapter(simple_response_adapter, SimpleResponse)
If you want to implement your own Response object instead of using the
:class:`pyramid.response.Response` object in any capacity at all, you'll have
to make sure the object implements every attribute and method outlined in
-:class:`pyramid.interfaces.IResponse` *and* you'll have to ensure that it's
+:class:`pyramid.interfaces.IResponse` and you'll have to ensure that it's
marked up with ``zope.interface.implements(IResponse)``:
from pyramid.interfaces import IResponse