X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsp%2Fxhtml.py;h=50c70b6e7e3260d5f70ee01549acc613ca246aec;hb=d38b200493b3ed263dbf10581d6d204462ed68c4;hp=a7debe62f07968c9b9b8c8259816c4d096bef25a;hpb=825ac8f0cafe69dfb61c127556ef50f0f92e6168;p=wrw.git diff --git a/wrw/sp/xhtml.py b/wrw/sp/xhtml.py index a7debe6..50c70b6 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) + super().addattr(node, self.attrmap.get(k, k), v) + def cons(ctx=None): + if ctx is None: ctx = xhtmlcontext() return _cons.constructor(ns, htmlelement, ctx) def head(title=None, css=None): @@ -45,9 +53,12 @@ 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): return forreq(req, callable(req)) + wrapper.__wrapped__ = callable return wrapper