X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsp%2Fxhtml.py;h=a2c1eb1160ae9daa1ee737b9fe1b22796d24c9d0;hb=7e9080af248b38edec371f117eb4749b09a3caca;hp=3c6c0f6898333ae89a28bc01b5a106fa17325b05;hpb=a573465ea03bd2a484252e87e0364d9376ec6bfc;p=wrw.git diff --git a/wrw/sp/xhtml.py b/wrw/sp/xhtml.py index 3c6c0f6..a2c1eb1 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.handle(">", el) + self.handle("<", 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