</body>
</html>""" % (self.head(title), content)
- def skel(self, title):
+ def head(self, title):
return """<title>%s</title>\n%s""" % (title, self.style())
def style(self):
return [skelfor(req).error(self.message, self.detail)]
class message(dispatch.restart):
- def __init__(self, message, detail):
+ def __init__(self, msg, detail):
super(message, self).__init__()
- self.message = message
+ self.message = msg
self.detail = detail
def handle(self, req):
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 []