summaryrefslogtreecommitdiff
path: root/repoze/bfg/events.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2010-09-06 00:06:48 +0000
committerChris McDonough <chrism@agendaless.com>2010-09-06 00:06:48 +0000
commiteb7ea411bfce55085449b79ac88aac19af0e232f (patch)
tree6c98b973c746d4c37a5d7f40078aefd9dd1c4d23 /repoze/bfg/events.py
parent8deae21c801bc05c6464a6eead3df449ed1fe52d (diff)
downloadpyramid-eb7ea411bfce55085449b79ac88aac19af0e232f.tar.gz
pyramid-eb7ea411bfce55085449b79ac88aac19af0e232f.tar.bz2
pyramid-eb7ea411bfce55085449b79ac88aac19af0e232f.zip
- The ``repoze.bfg.interfaces.INewResponse`` interface now includes a
``request`` attribute; as a result, a handler for INewResponse now has access to the request which caused the response. - The INewResponse event is now not sent to listeners if the response returned by view code (or a renderer) is not a "real" response (e.g. if it does not have ``.status``, ``.headerlist`` and ``.app_iter`` attribtues).
Diffstat (limited to 'repoze/bfg/events.py')
-rw-r--r--repoze/bfg/events.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/repoze/bfg/events.py b/repoze/bfg/events.py
index 22822eeeb..dd4f2eacc 100644
--- a/repoze/bfg/events.py
+++ b/repoze/bfg/events.py
@@ -82,8 +82,12 @@ class NewRequest(object):
class NewResponse(object):
""" An instance of this class is emitted as an :term:`event`
whenever any :mod:`repoze.bfg` view returns a :term:`response`.
- The instance has an attribute, ``response``, which is the response
- object returned by the view. This class implements the
+
+ The instance has two attributes:``request``, which is the request
+ which caused the response, and ``response``, which is the response
+ object returned by a view or renderer.
+
+ This class implements the
:class:`repoze.bfg.interfaces.INewResponse` interface.
.. note::
@@ -96,7 +100,8 @@ class NewResponse(object):
:class:`repoze.bfg.interfaces.INewRequest` event.
"""
implements(INewResponse)
- def __init__(self, response):
+ def __init__(self, request, response):
+ self.request = request
self.response = response
class AfterTraversal(object):