[Checkins] SVN: z3c.rml/trunk/src/z3c/rml/ Windows fix

Roger Ineichen roger at projekt01.ch
Wed Apr 4 12:23:55 EDT 2007


Log message for revision 74004:
  Windows fix

Changed:
  U   z3c.rml/trunk/src/z3c/rml/rml2pdf.py
  U   z3c.rml/trunk/src/z3c/rml/tests/test_rml.py

-=-
Modified: z3c.rml/trunk/src/z3c/rml/rml2pdf.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/rml2pdf.py	2007-04-04 15:03:08 UTC (rev 74003)
+++ z3c.rml/trunk/src/z3c/rml/rml2pdf.py	2007-04-04 16:23:54 UTC (rev 74004)
@@ -26,7 +26,13 @@
 zope.interface.moduleProvides(interfaces.IRML2PDF)
 
 
-def parseString(xml):
+def parseString(xml, removeEncodingLine=True):
+    if removeEncodingLine:
+        # RML is a unicode string, but oftentimes documents declare their
+        # encoding using <?xml ...>. Unfortuantely, I cannot tell lxml to
+        # ignore that directive. Thus we remove it.
+        if xml.startswith('<?xml'):
+            xml = xml.split('\n', 1)[-1]
     root = etree.fromstring(xml)
     doc = document.Document(root)
     output = cStringIO.StringIO()

Modified: z3c.rml/trunk/src/z3c/rml/tests/test_rml.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/tests/test_rml.py	2007-04-04 15:03:08 UTC (rev 74003)
+++ z3c.rml/trunk/src/z3c/rml/tests/test_rml.py	2007-04-04 16:23:54 UTC (rev 74004)
@@ -33,7 +33,7 @@
         self._fileOpen = attr.File.open
         def testOpen(img, filename):
             path = os.path.join(os.path.dirname(self._inPath), filename)
-            return open(path)
+            return open(path, 'rb')
         attr.File.open = testOpen
         import z3c.rml.tests.module
         sys.modules['module'] = z3c.rml.tests.module



More information about the Checkins mailing list