Log message for revision 72016: backported woraround for unicode issue in zope.tal.xmlparser.XMLParser.parseString()
Changed: U Zope/branches/2.10/lib/python/Products/PageTemplates/__init__.py U Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py -=- Modified: Zope/branches/2.10/lib/python/Products/PageTemplates/__init__.py =================================================================== --- Zope/branches/2.10/lib/python/Products/PageTemplates/__init__.py 2007-01-14 10:55:02 UTC (rev 72015) +++ Zope/branches/2.10/lib/python/Products/PageTemplates/__init__.py 2007-01-14 11:06:10 UTC (rev 72016) @@ -26,7 +26,30 @@ # available in sys.modules import ZTUtils + def initialize(context): # Import lazily, and defer initialization to the module import ZopePageTemplate ZopePageTemplate.initialize(context) + + +# HACK!!! +# We need to monkeypatch the parseString method of the Zope 3 +# XMLParser since the internal ZPT representation uses unicode +# however the XMLParser (using Expat) can only deal with standard +# Python strings. However we won't and can't convert directly +# to UTF-8 within the ZPT wrapper code. +# Unicode support for (this issue) should be directly added +# to zope.tal.xmlparser however this requires a new Zope 3.3.X +# release. For now we fix it here. + +from zope.tal.xmlparser import XMLParser +import logging + +def parseString(self, s): + if isinstance(s, unicode): + s = s.encode('utf-8') + self.parser.Parse(s, 1) + +XMLParser.parseString = parseString +logging.info('Monkeypatching zope.tal.xmlparser.XMLParser.parseString()') Modified: Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py =================================================================== --- Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py 2007-01-14 10:55:02 UTC (rev 72015) +++ Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py 2007-01-14 11:06:10 UTC (rev 72016) @@ -196,12 +196,14 @@ zpt = self._put(xml_iso_8859_15) self.assertEqual(zpt.output_encoding, 'utf-8') self.assertEqual(zpt.content_type, 'text/xml') + result = zpt.pt_render() # should not raise an exception def testPutXMLUTF8(self): """ XML: use always UTF-8 als output encoding """ zpt = self._put(xml_utf8) self.assertEqual(zpt.output_encoding, 'utf-8') self.assertEqual(zpt.content_type, 'text/xml') + result = zpt.pt_render() # should not raise an exception class ZPTRegressions(unittest.TestCase): _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins