X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fresp.py;h=7fae787f81a92c0f4447c81be0ffcdcc042c2265;hb=refs%2Fheads%2Fpython2;hp=50ac6b1ce1c25c9a96a21ecd12cb5cc6860195bd;hpb=7756066bff7ee01d615cbce0d5ddd58441108bd6;p=wrw.git diff --git a/wrw/resp.py b/wrw/resp.py index 50ac6b1..7fae787 100644 --- a/wrw/resp.py +++ b/wrw/resp.py @@ -45,7 +45,7 @@ class message(dispatch.restart): return skelfor(req).message(req, self.message, *self.detail) class httperror(usererror): - def __init__(self, status, message = None, detail = None): + def __init__(self, status, message=None, detail=None): if message is None: message = proto.statusinfo[status][0] if detail is None: @@ -62,14 +62,20 @@ class notfound(httperror): return super(notfound, self).__init__(404) class redirect(dispatch.restart): - def __init__(self, url, status = 303): + bases = {"url": proto.requrl, + "script": proto.scripturl, + "site": proto.siteurl} + + def __init__(self, url, status=303, base="url"): super(redirect, self).__init__() self.url = url self.status = status + self.bases[base] + self.base = base def handle(self, req): req.status(self.status, "Redirect") - req.ohead["Location"] = proto.appendurl(proto.requrl(req), self.url) + req.ohead["Location"] = proto.appendurl(self.bases[self.base](req), self.url) req.ohead["Content-Length"] = 0 return []