From: Fredrik Tolf Date: Sun, 6 Nov 2011 19:56:40 +0000 (+0100) Subject: Added a redirection restart. X-Git-Url: http://dolda2000.com/gitweb/?p=wrw.git;a=commitdiff_plain;h=4bd573f957065c9a1998b3c7202892319a004c95 Added a redirection restart. --- diff --git a/wrw/resp.py b/wrw/resp.py index 2e26ccf..8216d23 100644 --- a/wrw/resp.py +++ b/wrw/resp.py @@ -70,3 +70,14 @@ class httperror(usererror): class notfound(httperror): def __init__(self): return super(notfound, self).__init__(404) + +class redirect(dispatch.restart): + def __init__(self, url, status = 303): + super(redirect, self).__init__() + self.url = url + self.status = status + + def handle(self, req): + req.status(self.status, "Redirect") + req.ohead["Location"] = proto.appendurl(proto.requrl(req), self.url) + return []