summaryrefslogtreecommitdiff
path: root/docs/narr
diff options
context:
space:
mode:
authorJohn Anderson <sontek@gmail.com>2015-01-01 15:03:56 -0800
committerJohn Anderson <sontek@gmail.com>2015-01-01 15:03:56 -0800
commit32cb805132e8149a276a8c65fdfa961384e8254e (patch)
tree0ce71d880a54fd55a7403a7ec04c30d24eb0ee41 /docs/narr
parent807e941787e157db882fcd95e13f5cafb7ebde7f (diff)
downloadpyramid-32cb805132e8149a276a8c65fdfa961384e8254e.tar.gz
pyramid-32cb805132e8149a276a8c65fdfa961384e8254e.tar.bz2
pyramid-32cb805132e8149a276a8c65fdfa961384e8254e.zip
Mkae the response factory a factory that takes a request
Diffstat (limited to 'docs/narr')
-rw-r--r--docs/narr/hooks.rst29
1 files changed, 6 insertions, 23 deletions
diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst
index 689ce9dc2..e250c2d7e 100644
--- a/docs/narr/hooks.rst
+++ b/docs/narr/hooks.rst
@@ -369,10 +369,10 @@ Whenever :app:`Pyramid` returns a response from a view it creates a
:class:`pyramid.response.Response` class is created to represent the response
object.
-The class (aka "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.
+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:
@@ -382,7 +382,7 @@ callable or a :term:`dotted Python name` representing a callable.
class MyResponse(Response):
pass
- config = Configurator(response_factory=MyResponse)
+ 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
@@ -398,25 +398,8 @@ already constructed a :term:`configurator` it can also be registered via the
pass
config = Configurator()
- config.set_response_factory(MyRequest)
-
-If you are already using a custom ```request_factory`` you can also set the
-``ResponseClass`` on your :class:`pyramid.request.Request`:
-
-.. code-block:: python
- :linenos:
-
- from pyramid.config import Configurator
- from pyramid.response import Response
- from pyramid.request import Request
-
- class MyResponse(Response):
- pass
-
- class MyRequest(Request):
- ResponseClass = MyResponse
+ config.set_response_factory(lambda r: MyResponse())
- config = Configurator()
Using The Before Render Event
-----------------------------