From 4bd573f957065c9a1998b3c7202892319a004c95 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sun, 6 Nov 2011 20:56:40 +0100 Subject: [PATCH] Added a redirection restart. --- wrw/resp.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 [] -- 2.11.0