Skip to content
Browse files

- The ``pyramid.events.NewResponse`` event is now sent **after** resp…

…onse

  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.
  • Loading branch information...
1 parent 2291238 commit fc477b2e4b20ae2788e468e45b2831e774be8ced @mcdonc mcdonc committed Sep 7, 2013
Showing with 17 additions and 11 deletions.
  1. +5 −0 CHANGES.txt
  2. +3 −3 docs/api/request.rst
  3. +1 −1 docs/narr/hooks.rst
  4. +3 −3 docs/narr/subrequest.rst
  5. +5 −4 pyramid/router.py
View
5 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)
==================
View
6 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.
View
2 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.
View
6 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.
View
9 pyramid/router.py
@@ -212,13 +212,13 @@ def invoke_subrequest(self, request, use_tweens=False):
- 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 @@ def invoke_subrequest(self, request, use_tweens=False):
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:

0 comments on commit fc477b2

Please sign in to comment.
Something went wrong with that request. Please try again.