diff options
| author | Chris McDonough <chrism@plope.com> | 2010-10-25 10:29:31 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2010-10-25 10:29:31 -0400 |
| commit | 64372401084889a440c9d990a0febc221e3e4b5c (patch) | |
| tree | c8939a341505d19f19fa6918d264b4e1d95326f8 /repoze/bfg/exceptions.py | |
| parent | c8e78c2037806f3e5dab57de635bf80865b7061d (diff) | |
| download | pyramid-64372401084889a440c9d990a0febc221e3e4b5c.tar.gz pyramid-64372401084889a440c9d990a0febc221e3e4b5c.tar.bz2 pyramid-64372401084889a440c9d990a0febc221e3e4b5c.zip | |
first pass at converting bfg to pyramid namespace
Diffstat (limited to 'repoze/bfg/exceptions.py')
| -rw-r--r-- | repoze/bfg/exceptions.py | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/repoze/bfg/exceptions.py b/repoze/bfg/exceptions.py deleted file mode 100644 index 9b885d9dc..000000000 --- a/repoze/bfg/exceptions.py +++ /dev/null @@ -1,92 +0,0 @@ -from zope.configuration.exceptions import ConfigurationError as ZCE -from zope.interface import implements - -from repoze.bfg.decorator import reify -from repoze.bfg.interfaces import IExceptionResponse -import cgi - -class ExceptionResponse(Exception): - """ Abstract class to support behaving as a WSGI response object """ - implements(IExceptionResponse) - status = None - - def __init__(self, message=''): - Exception.__init__(self, message) # B / C - self.message = message - - @reify # defer execution until asked explicitly - def app_iter(self): - return [ - """ - <html> - <title>%s</title> - <body> - <h1>%s</h1> - <code>%s</code> - </body> - </html> - """ % (self.status, self.status, cgi.escape(self.message)) - ] - - @reify # defer execution until asked explicitly - def headerlist(self): - return [ - ('Content-Length', str(len(self.app_iter[0]))), - ('Content-Type', 'text/html') - ] - - -class Forbidden(ExceptionResponse): - """ - Raise this exception within :term:`view` code to immediately - return the :term:`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 by the router under the - ``repoze.bfg.message`` key, for availability to the - :term:`Forbidden View`. - """ - status = '401 Unauthorized' - -class NotFound(ExceptionResponse): - """ - Raise this exception within :term:`view` code to immediately - return the :term:`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 by the router under the - ``repoze.bfg.message`` key, for availability to the :term:`Not Found - View`. - """ - status = '404 Not Found' - -class PredicateMismatch(NotFound): - """ - Internal exception (not an API) raised by multiviews when no - view matches. This exception subclasses the ``NotFound`` - exception only one reason: if it reaches the main exception - handler, it should be treated like a ``NotFound`` by any exception - view registrations. - """ - -class URLDecodeError(UnicodeDecodeError): - """ - This exception is raised when :mod:`repoze.bfg` cannot - successfully decode a URL or a URL path segment. This exception - it behaves just like the Python builtin - :exc:`UnicodeDecodeError`. It is a subclass of the builtin - :exc:`UnicodeDecodeError` exception only for identity purposes, - mostly so an exception view can be registered when a URL cannot be - decoded. - """ - -class ConfigurationError(ZCE): - """ Raised when inappropriate input values are supplied to an API - method of a :term:`Configurator`""" - |
