Allow setting attributes to None as a noop, for convenience.
[wrw.git] / wrw / sp / xhtml.py
index 3c6c0f6..f10d315 100644 (file)
@@ -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()
@@ -53,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")
-    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