summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2012-03-02 01:03:15 -0800
committerChris McDonough <chrism@plope.com>2012-03-02 01:03:15 -0800
commit1757f08f32e4708156b494d9b4411bd19f18a01e (patch)
tree6ee4f40ea802d0a5dd0b4630e8ec85dd7439973e
parent3a14206e0f03fe24fa9a6611097230607332184d (diff)
parentae6d08b96d3a366f979719c05926dc5292d904d3 (diff)
downloadpyramid-1757f08f32e4708156b494d9b4411bd19f18a01e.tar.gz
pyramid-1757f08f32e4708156b494d9b4411bd19f18a01e.tar.bz2
pyramid-1757f08f32e4708156b494d9b4411bd19f18a01e.zip
Merge pull request #455 from rspivak/ae6d08b96d3a366f979719c05926dc5292d904d3
Finished callbacks documentation update
-rw-r--r--docs/narr/hooks.rst21
1 files changed, 7 insertions, 14 deletions
diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst
index f1a122c6c..24ea5de21 100644
--- a/docs/narr/hooks.rst
+++ b/docs/narr/hooks.rst
@@ -421,15 +421,14 @@ parameter: ``request``. For example:
.. code-block:: python
:linenos:
- import transaction
+ import logging
- def commit_callback(request):
- '''commit or abort the transaction associated with request'''
- if request.exception is not None:
- transaction.abort()
- else:
- transaction.commit()
- request.add_finished_callback(commit_callback)
+ log = logging.getLogger(__name__)
+
+ def log_callback(request):
+ """Log information at the end of request"""
+ log.debug('Request is finished.')
+ request.add_finished_callback(log_callback)
Finished callbacks are called in the order they're added
(first-to-most-recently-added). Finished callbacks (unlike a
@@ -447,12 +446,6 @@ meaningful effect, because response processing will have already occurred,
and the request's scope will expire almost immediately after all finished
callbacks have been processed.
-It is often necessary to tell whether an exception occurred within
-:term:`view callable` code from within a finished callback: in such a case,
-the :attr:`request.exception` attribute of the request when it enters a
-response callback will be an exception object instead of its default value of
-``None``.
-
Errors raised by finished callbacks are not handled specially. They
will be propagated to the caller of the :app:`Pyramid` router
application.