X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fresp.py;h=50ac6b1ce1c25c9a96a21ecd12cb5cc6860195bd;hb=7756066bff7ee01d615cbce0d5ddd58441108bd6;hp=9ad22d1126e2fb4af2852fb50b985c0533d07f4a;hpb=ef04ec8791734c918a5b8940976bf3fde3618710;p=wrw.git diff --git a/wrw/resp.py b/wrw/resp.py index 9ad22d1..50ac6b1 100644 --- a/wrw/resp.py +++ b/wrw/resp.py @@ -5,17 +5,17 @@ h = xhtml.cons() __all__ = ["skeleton", "skelfor", "setskel", "usererror"] class skeleton(object): - def page(self, title, *content): - return h.html(self.head(title), h.body(*content)) + def page(self, req, title, *content): + return xhtml.forreq(req, h.html(self.head(req, title), h.body(*content))) - def head(self, title): + def head(self, req, title): return xhtml.head(title=title) - def error(self, message, *detail): - return self.page(message, h.h1(message), h.p(*detail)) + def error(self, req, message, *detail): + return self.page(req, message, h.h1(message), h.p(*detail)) - def message(self, message, *detail): - return self.page(message, h.h1(message), h.p(*detail)) + def message(self, req, message, *detail): + return self.page(req, message, h.h1(message), h.p(*detail)) defskel = env.var(skeleton()) @@ -33,7 +33,7 @@ class usererror(dispatch.restart): self.detail = detail def handle(self, req): - return xhtml.forreq(req, skelfor(req).error(self.message, *self.detail)) + return skelfor(req).error(req, self.message, *self.detail) class message(dispatch.restart): def __init__(self, msg, *detail): @@ -42,7 +42,7 @@ class message(dispatch.restart): self.detail = detail def handle(self, req): - return xhtml.forreq(req, skelfor(req).error(self.message, *self.detail)) + return skelfor(req).message(req, self.message, *self.detail) class httperror(usererror): def __init__(self, status, message = None, detail = None): @@ -70,4 +70,11 @@ class redirect(dispatch.restart): def handle(self, req): req.status(self.status, "Redirect") req.ohead["Location"] = proto.appendurl(proto.requrl(req), self.url) + req.ohead["Content-Length"] = 0 + return [] + +class unmodified(dispatch.restart): + def handle(self, req): + req.status(304, "Not Modified") + req.ohead["Content-Length"] = "0" return []