X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsp%2Fxhtml.py;h=52e7f9f8e653c5d679d300a15c34dd8d6c4396fe;hb=3b67497cb853ea7dd49f579566e5f0b60a3c97d7;hp=a7debe62f07968c9b9b8c8259816c4d096bef25a;hpb=3e91bb195838a6c561358a44f654f41f46e9c95f;p=wrw.git diff --git a/wrw/sp/xhtml.py b/wrw/sp/xhtml.py index a7debe6..52e7f9f 100644 --- a/wrw/sp/xhtml.py +++ b/wrw/sp/xhtml.py @@ -14,7 +14,15 @@ class htmlelement(_cons.element): doc.appendChild(self.__todom__(doc)) return doc +class xhtmlcontext(_cons.context): + attrmap = {"klass": "class"} + + def addattr(self, node, k, v): + k = str(k) + node.attrs[self.attrmap.get(k, k)] = str(v) + def cons(ctx=None): + if ctx is None: ctx = xhtmlcontext() return _cons.constructor(ns, htmlelement, ctx) def head(title=None, css=None): @@ -45,7 +53,9 @@ def forreq(req, tree): req.ohead["Content-Type"] = "text/html; charset=utf-8" buf = io.BytesIO() 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):