X-Git-Url: http://dolda2000.com/gitweb/?p=wrw.git;a=blobdiff_plain;f=wrw%2Fresp.py;h=fbb056f7fe35a7de8a138312862df1c44822a966;hp=50ac6b1ce1c25c9a96a21ecd12cb5cc6860195bd;hb=d0034deebc5dc1fc5a54d1e99fe917f9ffbe7d69;hpb=3985f4bbbfd3740d955ec766fb5fb912efcb0d59 diff --git a/wrw/resp.py b/wrw/resp.py index 50ac6b1..fbb056f 100644 --- a/wrw/resp.py +++ b/wrw/resp.py @@ -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 []