summaryrefslogtreecommitdiff
path: root/paste/httpexceptions.py
diff options
context:
space:
mode:
authorianb <devnull@localhost>2007-02-19 02:08:01 +0000
committerianb <devnull@localhost>2007-02-19 02:08:01 +0000
commit3317c08db036ffbfe6c6f96530d6e9d8b05c34d6 (patch)
treea41623c110cae41910e68e2c794daa343f30e055 /paste/httpexceptions.py
parent13f2b58b6f8d9695522137b759c7a5d1dcd356b3 (diff)
downloadpaste-3317c08db036ffbfe6c6f96530d6e9d8b05c34d6.tar.gz
add .response() method to HTTPException objects (from damjam)
Diffstat (limited to 'paste/httpexceptions.py')
-rw-r--r--paste/httpexceptions.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/paste/httpexceptions.py b/paste/httpexceptions.py
index 5792d76..ce8bef2 100644
--- a/paste/httpexceptions.py
+++ b/paste/httpexceptions.py
@@ -222,10 +222,7 @@ class HTTPException(Exception):
'server': SERVER_NAME,
'body': body }
- def wsgi_application(self, environ, start_response, exc_info=None):
- """
- This exception as a WSGI application
- """
+ def prepare_content(self, environ):
if self.headers:
headers = list(self.headers)
else:
@@ -245,6 +242,20 @@ class HTTPException(Exception):
replace_header(
headers, 'content-type',
cur_content_type + '; charset=utf8')
+ return headers, content
+
+ def response(self, environ):
+ from paste.wsgiwrappers import WSGIResponse
+ headers, content = self.prepare_content(environ)
+ resp = WSGIResponse(code=self.code, content=content)
+ resp.headers.update(dict(headers))
+ return resp
+
+ def wsgi_application(self, environ, start_response, exc_info=None):
+ """
+ This exception as a WSGI application
+ """
+ headers, content = self.prepare_content(environ)
start_response('%s %s' % (self.code, self.title),
headers,
exc_info)