diff options
author | ianb <devnull@localhost> | 2005-05-22 06:25:16 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2005-05-22 06:25:16 +0000 |
commit | 3a50de28d713b61aab14bc5b2219b226b4e058b8 (patch) | |
tree | 27e7fd726bb617b082c04f1996571866c682bfdc /paste/httpexceptions.py | |
parent | 4426ea904aa4c6788d939814b0270d61a92ab67a (diff) | |
download | paste-3a50de28d713b61aab14bc5b2219b226b4e058b8.tar.gz |
Added documentation to httpexceptions, and a special extractor for HTTPException subclasses
Diffstat (limited to 'paste/httpexceptions.py')
-rw-r--r-- | paste/httpexceptions.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/paste/httpexceptions.py b/paste/httpexceptions.py index 01d68f5..16fca6f 100644 --- a/paste/httpexceptions.py +++ b/paste/httpexceptions.py @@ -196,12 +196,14 @@ class HTTPHttpVersionNotSupported(HTTPException): title = 'HTTP Version Not Supported' message = ('The HTTP version is not supported.') +__all__ = [] _exceptions = {} for name, value in globals().items(): if (isinstance(value, (type, types.ClassType)) and issubclass(value, HTTPException) and value.code): _exceptions[value.code] = value + __all__.append(name) def get_exception(code): return _exceptions[code] @@ -211,6 +213,11 @@ def get_exception(code): def middleware(application): + """ + This middleware catches any exceptions (which are subclasses of + `HTTPException`) and turns them into proper HTTP responses. + """ + def start_application(environ, start_response): app_started = [] def checked_start_response(status, headers, exc_info=None): @@ -232,3 +239,6 @@ def middleware(application): return [e.html(environ)] return start_application + +__all__.extend(['middleware', 'get_exception']) + |