summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-09-07 21:59:41 -0400
committerChris McDonough <chrism@plope.com>2013-09-07 21:59:41 -0400
commitfc477b2e4b20ae2788e468e45b2831e774be8ced (patch)
treebc04c88bc9aeda9469e5ee8b0cf27de482561db4
parent2291238b72b6603b475a8551f3b4f2c178e2ba81 (diff)
downloadpyramid-fc477b2e4b20ae2788e468e45b2831e774be8ced.tar.gz
pyramid-fc477b2e4b20ae2788e468e45b2831e774be8ced.tar.bz2
pyramid-fc477b2e4b20ae2788e468e45b2831e774be8ced.zip
- The ``pyramid.events.NewResponse`` event is now sent **after** response
callbacks are executed. It previously executed before response callbacks were executed. Rationale: it's more useful to be able to inspect the response after response callbacks have done their jobs instead of before. Closes #1116.
-rw-r--r--CHANGES.txt5
-rw-r--r--docs/api/request.rst6
-rw-r--r--docs/narr/hooks.rst2
-rw-r--r--docs/narr/subrequest.rst6
-rw-r--r--pyramid/router.py9
5 files changed, 17 insertions, 11 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 668a696f1..64b269f80 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -27,6 +27,11 @@ Backwards Incompatibilities
- Removed the ``bfg2pyramid`` fixer script.
+- The ``pyramid.events.NewResponse`` event is now sent **after** response
+ callbacks are executed. It previously executed before response callbacks
+ were executed. Rationale: it's more useful to be able to inspect the response
+ after response callbacks have done their jobs instead of before.
+
1.5a1 (2013-08-30)
==================
diff --git a/docs/api/request.rst b/docs/api/request.rst
index ef41ba4c8..72abddb68 100644
--- a/docs/api/request.rst
+++ b/docs/api/request.rst
@@ -199,13 +199,13 @@
- Ensures that the user implied by the request passed has the necessary
authorization to invoke view callable before calling it.
- - causes a :class:`~pyramid.events.NewResponse` event to be sent when
- the Pyramid application returns a response.
-
- Calls any :term:`response callback` functions defined within the
request's lifetime if a response is obtained from the Pyramid
application.
+ - causes a :class:`~pyramid.events.NewResponse` event to be sent if a
+ response is obtained.
+
- Calls any :term:`finished callback` functions defined within the
request's lifetime.
diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst
index 3a2568775..8ffda1a5f 100644
--- a/docs/narr/hooks.rst
+++ b/docs/narr/hooks.rst
@@ -514,7 +514,7 @@ callback will be an exception object instead of its default value of
``None``.
Response callbacks are called in the order they're added
-(first-to-most-recently-added). All response callbacks are called *after*
+(first-to-most-recently-added). All response callbacks are called *before*
the :class:`~pyramid.events.NewResponse` event is sent. Errors raised by
response callbacks are not handled specially. They will be propagated to the
caller of the :app:`Pyramid` router application.
diff --git a/docs/narr/subrequest.rst b/docs/narr/subrequest.rst
index 6437bd0fa..4b4e99d41 100644
--- a/docs/narr/subrequest.rst
+++ b/docs/narr/subrequest.rst
@@ -232,12 +232,12 @@ unconditionally:
- Ensures that the user implied by the request passed has the necessary
authorization to invoke view callable before calling it.
-- causes a :class:`~pyramid.events.NewResponse` event to be sent when the
- Pyramid application returns a response.
-
- Calls any :term:`response callback` functions defined within the subrequest's
lifetime if a response is obtained from the Pyramid application.
+- causes a :class:`~pyramid.events.NewResponse` event to be sent if a response
+ is obtained.
+
- Calls any :term:`finished callback` functions defined within the subrequest's
lifetime.
diff --git a/pyramid/router.py b/pyramid/router.py
index 1a991648b..6239f3980 100644
--- a/pyramid/router.py
+++ b/pyramid/router.py
@@ -212,13 +212,13 @@ class Router(object):
- causes a :class:`~pyramid.event.ContextFound` event to be sent
when a context resource is found.
- - causes a :class:`~pyramid.event.NewResponse` event to be sent when
- the Pyramid application returns a response.
-
- Calls any :term:`response callback` functions defined within the
request's lifetime if a response is obtained from the Pyramid
application.
+ - causes a :class:`~pyramid.event.NewResponse` event to be sent if a
+ response is obtained.
+
- Calls any :term:`finished callback` functions defined within the
request's lifetime.
@@ -245,11 +245,12 @@ class Router(object):
if extensions is not None:
request._set_extensions(extensions)
response = handle_request(request)
- has_listeners and notify(NewResponse(request, response))
if request.response_callbacks:
request._process_response_callbacks(response)
+ has_listeners and notify(NewResponse(request, response))
+
return response
finally: