diff options
author | ianb <devnull@localhost> | 2006-02-02 06:06:00 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2006-02-02 06:06:00 +0000 |
commit | a4a76101efeed6833e239221397ec8f6035beeee (patch) | |
tree | a6f11cc2c870e8a70dd3994a60fa52c74da4a7b1 /paste/httpexceptions.py | |
parent | 3f55e2a4fb342322c14bfa3fb3686d4bbb68d2cf (diff) | |
download | paste-a4a76101efeed6833e239221397ec8f6035beeee.tar.gz |
Added relative_redirect classmethod constructor to redirect exceptions
Diffstat (limited to 'paste/httpexceptions.py')
-rw-r--r-- | paste/httpexceptions.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/paste/httpexceptions.py b/paste/httpexceptions.py index b61d8bc..4f2f366 100644 --- a/paste/httpexceptions.py +++ b/paste/httpexceptions.py @@ -74,6 +74,7 @@ References: import types from wsgilib import catch_errors_app from response import has_header, header_value +from request import resolve_relative_url from util.quoting import strip_html, html_quote, no_quote SERVER_NAME = 'WSGI Server' @@ -313,6 +314,18 @@ class _HTTPMove(HTTPRedirection): if detail is not None: self.detail = detail + def relative_redirect(cls, dest_uri, environ, detail=None, headers=None, comment=None): + """ + Create a redirect object with the dest_uri, which may be relative, + considering it relative to the uri implied by the given environ. + """ + location = resolve_relative_url(dest_uri, environ) + headers = headers or [] + headers.append(('Location', location)) + return cls(detail=detail, headers=headers, comment=comment) + + relative_redirect = classmethod(relative_redirect) + class HTTPMultipleChoices(_HTTPMove): code = 300 title = 'Multiple Choices' |