X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsp%2Fxhtml.py;h=48ed41d7723b01a96e19d12add255833a6c22354;hb=fb5f9f27dcabe7fac75e3a69f820c42779539239;hp=3c6c0f6898333ae89a28bc01b5a106fa17325b05;hpb=a573465ea03bd2a484252e87e0364d9376ec6bfc;p=wrw.git diff --git a/wrw/sp/xhtml.py b/wrw/sp/xhtml.py index 3c6c0f6..48ed41d 100644 --- a/wrw/sp/xhtml.py +++ b/wrw/sp/xhtml.py @@ -19,7 +19,7 @@ class xhtmlcontext(_cons.context): def addattr(self, node, k, v): k = unicode(k) - node.attrs[self.attrmap.get(k, k)] = unicode(v) + super(xhtmlcontext, self).addattr(node, self.attrmap.get(k, k), v) def cons(ctx=None): if ctx is None: ctx = xhtmlcontext() @@ -39,13 +39,14 @@ def head(title=None, css=None): class htmlformatter(util.formatter): allowshort = set([u"br", u"hr", u"img", u"input", u"meta", u"link"]) - def element(self, el, **extra): + def shorttag(self, el): if el.name in self.allowshort: - super(htmlformatter, self).element(el, **extra) + super(htmlformatter, self).shorttag(el) else: - self.longtag(el, **extra) + self.starttag(el) + self.endtag(el) -class htmlindenter(util.indenter, htmlformatter): +class htmlindenter(util.textindenter, htmlformatter): pass def forreq(req, tree): @@ -53,9 +54,12 @@ def forreq(req, tree): req.ohead["Content-Type"] = "text/html; charset=utf-8" buf = StringIO.StringIO() htmlindenter.output(buf, tree, doctype=(doctype, dtd), charset="utf-8") - return [buf.getvalue()] + ret = buf.getvalue() + req.ohead["Content-Length"] = len(ret) + return [ret] def xhtmlresp(callable): def wrapper(req): return forreq(req, callable(req)) + wrapper.__wrapped__ = callable return wrapper