Dolda2000 GitWeb
/
wrw.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Do Unicode conversion from bytestring more properly.
[wrw.git]
/
wrw
/
sp
/
xhtml.py
diff --git
a/wrw/sp/xhtml.py
b/wrw/sp/xhtml.py
index
928dcd9
..
f10d315
100644
(file)
--- 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
doc.appendChild(self.__todom__(doc))
return doc
+class xhtmlcontext(_cons.context):
+ attrmap = {u"klass": u"class"}
+
+ def addattr(self, node, k, v):
+ k = unicode(k)
+ super(xhtmlcontext, self).addattr(node, self.attrmap.get(k, k), v)
+
def cons(ctx=None):
def cons(ctx=None):
+ if ctx is None: ctx = xhtmlcontext()
return _cons.constructor(ns, htmlelement, ctx)
def head(title=None, css=None):
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 = StringIO.StringIO()
htmlindenter.output(buf, tree, doctype=(doctype, dtd), charset="utf-8")
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))
def xhtmlresp(callable):
def wrapper(req):
return forreq(req, callable(req))
+ wrapper.__wrapped__ = callable
return wrapper
return wrapper