diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-10-21 16:02:24 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-10-21 16:02:24 +0000 |
| commit | ef5149051623da25d24002132828c658b6dcfee4 (patch) | |
| tree | d608e7156cf2a3b6214951f9cce0f43d185e59ea /repoze/bfg/exceptions.py | |
| parent | 7c28d427199a5d2129c129be8f3260cb6bd9f7b0 (diff) | |
| download | pyramid-ef5149051623da25d24002132828c658b6dcfee4.tar.gz pyramid-ef5149051623da25d24002132828c658b6dcfee4.tar.bz2 pyramid-ef5149051623da25d24002132828c658b6dcfee4.zip | |
Add Respond exception.
Diffstat (limited to 'repoze/bfg/exceptions.py')
| -rw-r--r-- | repoze/bfg/exceptions.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/repoze/bfg/exceptions.py b/repoze/bfg/exceptions.py index afd617a2c..bc05fa699 100644 --- a/repoze/bfg/exceptions.py +++ b/repoze/bfg/exceptions.py @@ -22,3 +22,29 @@ class NotFound(Exception): into the WSGI environment under the ``repoze.bfg.message`` key, for availability to the Not Found view.""" +class Respond(Exception): + """\ + Raise this exception during view execution to return a response + immediately without proceeeding any further through the codepath. + Use of this exception is effectively a 'goto': its target is the + exception handler within the :mod:`repoze.bfg' router that catches + the exception and returns a response immediately. Note that + because this exception is caught by the router, it will not + propagate to any WSGI middleware. Note that this exception is + typically only used by the framework itself and by authentication + plugins to the framework. + + The exception must be initialized which a single argument, which + is a :term:`response` object. + + An example: + + .. code-block:: python + :linenos: + + from webob.exc import HTTPFound + from repoze.bfg.exceptions import Respond + response = HTTPFound(location='http://example.com') + raise Respond(response) + """ + |
