blob: bc05fa699b147b4c731d5362d866352922e9aa51 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
class Forbidden(Exception):
"""\
Raise this exception within :term:`view` code to immediately
return the Forbidden view to the invoking user. Usually this is a
basic ``401`` page, but the Forbidden view can be customized as
necessary. See :ref:`changing_the_forbidden_view`.
This exception's constructor accepts a single positional argument,
which should be a string. The value of this string will be placed
into the WSGI environment under the ``repoze.bfg.message`` key,
for availability to the Forbidden view."""
class NotFound(Exception):
"""\
Raise this exception within :term:`view` code to immediately
return the Not Found view to the invoking user. Usually this is a
basic ``404`` page, but the Not Found view can be customized as
necessary. See :ref:`changing_the_notfound_view`.
This exception's constructor accepts a single positional argument,
which should be a string. The value of this string will be placed
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)
"""
|