summaryrefslogtreecommitdiff
path: root/paste/httpexceptions.py
diff options
context:
space:
mode:
authorianb <devnull@localhost>2005-12-13 07:49:35 +0000
committerianb <devnull@localhost>2005-12-13 07:49:35 +0000
commit33111b10c035575d7b59b81da8a83593a4cf5416 (patch)
treea93216bb26d29c5131196098642885d096f9f45b /paste/httpexceptions.py
parent7e6f5e07a7ca05f7f5eb60dc0ed0f101d41e9c42 (diff)
downloadpaste-33111b10c035575d7b59b81da8a83593a4cf5416.tar.gz
Deprecated httpexceptions.middleware; split the httpexceptions middleware from its paste.deploy setup function
Diffstat (limited to 'paste/httpexceptions.py')
-rw-r--r--paste/httpexceptions.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/paste/httpexceptions.py b/paste/httpexceptions.py
index 5b64472..3477c03 100644
--- a/paste/httpexceptions.py
+++ b/paste/httpexceptions.py
@@ -525,7 +525,7 @@ class HTTPExceptionHandler:
"""
- def __init__(self, application, global_conf=None, warning_level=None):
+ def __init__(self, application, warning_level=None):
assert not warning_level or ( warning_level > 99 and
warning_level < 600)
self.warning_level = warning_level or 500
@@ -558,7 +558,28 @@ class HTTPExceptionHandler:
for chunk in result:
yield chunk
-middleware = HTTPExceptionHandler
+def middleware(*args, **kw):
+ import warnings
+ # deprecated 13 dec 2005
+ warnings.warn('httpexceptions.middleware is deprecated; use '
+ 'HTTPExceptionHandler instead',
+ DeprecationWarning, 1)
+ return HTTPExceptionHandler(*args, **kw)
+
+def make_middleware(app, global_conf, warning_level=None):
+ """
+ ``httpexceptions`` middleware; this catches any
+ ``paste.httpexceptions.HTTPException`` exceptions (exceptions like
+ ``HTTPNotFound``, ``HTTPMovedPermanently``, etc) and turns them
+ into proper HTTP responses.
+
+ ``warning_level`` can be an integer corresponding to an HTTP code.
+ Any code over that value will be passed 'up' the chain, potentially
+ reported on by another piece of middleware.
+ """
+ if warning_level:
+ warning_level = int(warning_level)
+ return HTTPExceptionHandler(app, warning_level=warning_level)
__all__.extend(['HTTPExceptionHandler', 'get_exception'])