[py-svn] r34244 - in py/dist/py: . documentation xmlobj xmlobj/testing

mwh at codespeak.net mwh at codespeak.net
Sun Nov 5 16:38:12 CET 2006


Author: mwh
Date: Sun Nov  5 16:38:10 2006
New Revision: 34244

Modified:
   py/dist/py/__init__.py
   py/dist/py/documentation/confrest.py
   py/dist/py/xmlobj/testing/test_xml.py
   py/dist/py/xmlobj/visit.py
   py/dist/py/xmlobj/xml.py
Log:
add a py.xml.raw() object that can include html/xml directly in a py.xml.Tag()
(i.e. without any escaping).
use this in confrest.Project.process, which will hopefully unbreak
http://codespeak.net/py/current/doc/
(my first py lib checkin, i think :-)



(guido: this was your fault)


Modified: py/dist/py/__init__.py
==============================================================================
--- py/dist/py/__init__.py	(original)
+++ py/dist/py/__init__.py	Sun Nov  5 16:38:10 2006
@@ -109,6 +109,7 @@
     # small and mean xml/html generation
     'xml.html'               : ('./xmlobj/html.py', 'html'),
     'xml.Tag'                : ('./xmlobj/xml.py', 'Tag'),
+    'xml.raw'                : ('./xmlobj/xml.py', 'raw'),
     'xml.Namespace'          : ('./xmlobj/xml.py', 'Namespace'),
     'xml.escape'             : ('./xmlobj/misc.py', 'escape'),
 

Modified: py/dist/py/documentation/confrest.py
==============================================================================
--- py/dist/py/documentation/confrest.py	(original)
+++ py/dist/py/documentation/confrest.py	Sun Nov  5 16:38:10 2006
@@ -116,7 +116,7 @@
             html.div(html.div(modified, style="float: right; font-style: italic;"), 
                      id = 'docinfoline'))
 
-        page.contentspace.append(content) 
+        page.contentspace.append(py.xml.raw(content))
         htmlpath = txtpath.new(ext='.html') 
         htmlpath.write(page.unicode().encode(encoding)) 
 

Modified: py/dist/py/xmlobj/testing/test_xml.py
==============================================================================
--- py/dist/py/xmlobj/testing/test_xml.py	(original)
+++ py/dist/py/xmlobj/testing/test_xml.py	Sun Nov  5 16:38:10 2006
@@ -51,3 +51,7 @@
     u = unicode(x)
     assert u == '<some name="hello & world"/>'
 
+def test_raw():
+    x = ns.some(py.xml.raw("<p>literal</p>"))
+    u = unicode(x)
+    assert u == "<some><p>literal</p></some>"

Modified: py/dist/py/xmlobj/visit.py
==============================================================================
--- py/dist/py/xmlobj/visit.py	(original)
+++ py/dist/py/xmlobj/visit.py	Sun Nov  5 16:38:10 2006
@@ -34,6 +34,9 @@
         #self.write(obj) 
         self.write(escape(unicode(obj)))
 
+    def raw(self, obj):
+        self.write(obj.uniobj) 
+
     def list(self, obj):  
         assert id(obj) not in self.visited
         self.visited[id(obj)] = 1

Modified: py/dist/py/xmlobj/xml.py
==============================================================================
--- py/dist/py/xmlobj/xml.py	(original)
+++ py/dist/py/xmlobj/xml.py	Sun Nov  5 16:38:10 2006
@@ -24,6 +24,12 @@
         name = self.__class__.__name__ 
         return "<%r tag object %d>" % (name, id(self))
 
+class raw(object):
+    """just a box that can contain a unicode string that will be
+    included directly in the output"""
+    def __init__(self, uniobj):
+        self.uniobj = uniobj
+
 # the generic xml namespace 
 # provides Tag classes on the fly optionally checking for
 # a tagspecification 



More information about the pytest-commit mailing list