From eb7ea411bfce55085449b79ac88aac19af0e232f Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 6 Sep 2010 00:06:48 +0000 Subject: - 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). --- repoze/bfg/events.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'repoze/bfg/events.py') 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): -- cgit v1.2.3