X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fresp.py;h=04f3cabe6d5d8d7be055d2b9a985d505cea0310a;hb=fed807e31c96fef8d941b34a25a1f5044b2d4e8d;hp=030d5ee4385a6f1a9d3e4e8f905a3f9bddfb0a7f;hpb=dc7e5d54e72fd9a22f1509df0c7bbf05f8db8924;p=wrw.git diff --git a/wrw/resp.py b/wrw/resp.py index 030d5ee..04f3cab 100644 --- a/wrw/resp.py +++ b/wrw/resp.py @@ -1,4 +1,4 @@ -import dispatch, proto +from . import dispatch, proto __all__ = ["skeleton", "skelfor", "setskel", "usererror"] @@ -15,7 +15,7 @@ class skeleton(object): """ % (self.head(title), content) - def skel(self, title): + def head(self, title): return """%s\n%s""" % (title, self.style()) def style(self): @@ -65,8 +65,19 @@ class httperror(usererror): def handle(self, req): req.status(self.status, self.message) - super(httperror, self).handle(req) + return super(httperror, self).handle(req) class notfound(httperror): def __init__(self): - super(notfound, self).__init__(404) + 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 []