Commits

Ronny Pfannschmidt  committed b06f66a

finish xmlgen patches

  • Participants
  • Parent commits 60d2757

Comments (0)

Files changed (3)

 capture-bytes
 xmlgen-real-unicode
 xmlgen-object
+xmlgen-raw-attr

File xmlgen-object

 # HG changeset patch
 # Parent 1b68b3728002cdbfd2ac00cc7befa65bc40aed28
-special case for tags in xmlgen to work for the object tag
+special case for tags in xmlgen to work for the object tag, fixes #13
 
+diff --git a/CHANGELOG b/CHANGELOG
+--- a/CHANGELOG
++++ b/CHANGELOG
+@@ -1,3 +1,8 @@
++Changes between 1.4.7 and 1.4.8
++==================================================
++
++- fix issue 13 - correct handling of the tag name object in xmlgen
++
+ Changes between 1.4.6 and 1.4.7
+ ==================================================
+ 
 diff --git a/py/_xmlgen.py b/py/_xmlgen.py
 --- a/py/_xmlgen.py
 +++ b/py/_xmlgen.py
      assert (h.unicode(indent=2) ==
              '<div><span>foo</span><span>bar</span></div>')
  
-+def test_objct_tags():
++def test_object_tags():
 +    o = html.object(html.object())
-+    assert o.unicode() == '<object><object></object></object>'
++    assert o.unicode(indent=0) == '<object><object></object></object>'

File xmlgen-raw-attr

+# HG changeset patch
+# Parent c4b10e99d306fb1143d36d3134348396a5ed5a42
+xmlgen: support using raw for attribute values, fixes #14
+
+diff --git a/CHANGELOG b/CHANGELOG
+--- a/CHANGELOG
++++ b/CHANGELOG
+@@ -2,6 +2,7 @@ Changes between 1.4.7 and 1.4.8
+ ==================================================
+ 
+ - fix issue 13 - correct handling of the tag name object in xmlgen
++- fix issue 14 - support raw attribute values in xmlgen
+ 
+ Changes between 1.4.6 and 1.4.7
+ ==================================================
+diff --git a/py/_xmlgen.py b/py/_xmlgen.py
+--- a/py/_xmlgen.py
++++ b/py/_xmlgen.py
+@@ -186,7 +186,11 @@ class SimpleUnicodeVisitor(object):
+             value = getattr(attrs, name)
+             if name.endswith('_'):
+                 name = name[:-1]
+-            return ' %s="%s"' % (name, escape(unicode(value)))
++            if isinstance(value, raw):
++                insert = value.uniobj
++            else:
++                insert = escape(unicode(value))
++            return ' %s="%s"' % (name, insert)
+ 
+     def getstyle(self, tag):
+         """ return attribute list suitable for styling. """
+diff --git a/testing/root/test_xmlgen.py b/testing/root/test_xmlgen.py
+--- a/testing/root/test_xmlgen.py
++++ b/testing/root/test_xmlgen.py
+@@ -1,6 +1,6 @@
+ 
+ import py
+-from py._xmlgen import unicode, html
++from py._xmlgen import unicode, html, raw
+ 
+ class ns(py.xml.Namespace):
+     pass
+@@ -47,6 +47,10 @@ def test_tag_with_subclassed_attr_simple
+     assert x.attr.hello == 'world'
+     assert unicode(x) == '<my hello="world"/>'
+ 
++def test_tag_with_raw_attr():
++    x = html.object(data=raw('&'))
++    assert unicode(x) == '<object data="&"></object>'
++
+ def test_tag_nested():
+     x = ns.hello(ns.world())
+     unicode(x) # triggers parentifying