[ZPT] CVS: Zope27/lib/python/Products/PageTemplates - PageTemplate.py:1.24.18.1

Florent Guillaume fg@nuxeo.com
Sun, 8 Sep 2002 22:05:22 -0400


Update of /cvs-repository/Zope27/lib/python/Products/PageTemplates
In directory cvs.zope.org:/tmp/cvs-serv14808/lib/python/Products/PageTemplates

Modified Files:
      Tag: Zope-2_7-development-branch
	PageTemplate.py 
Log Message:
Provide an opportunity for third-party products to use a full
Unicode-aware StringIO by monkey-patching two appropriate methods
until one is completely integrated into Zope.


=== Zope27/lib/python/Products/PageTemplates/PageTemplate.py 1.24 => 1.24.18.1 ===
--- Zope27/lib/python/Products/PageTemplates/PageTemplate.py:1.24	Fri Apr 19 10:16:09 2002
+++ Zope27/lib/python/Products/PageTemplates/PageTemplate.py	Sun Sep  8 22:04:52 2002
@@ -24,7 +24,8 @@
 from TAL.TALGenerator import TALGenerator
 from TAL.TALInterpreter import TALInterpreter
 from Expressions import getEngine
-from cStringIO import StringIO
+# Do not use cStringIO here!  It's not unicode aware. :(
+from StringIO import StringIO
 from ExtensionClass import Base
 from ComputedAttribute import ComputedAttribute
 
@@ -43,6 +44,11 @@
     _text = ''
     _error_start = '<!-- Page Template Diagnostics'
 
+    def StringIO(self):
+        # Third-party products wishing to provide a full Unicode-aware
+        # StringIO can do so by monkey-patching this method.
+        return StringIO()
+
     def macros(self):
         return self.pt_macros()
     macros = ComputedAttribute(macros, 1)
@@ -80,7 +86,7 @@
 
         if self._v_errors:
             raise PTRuntimeError, 'Page Template %s has errors.' % self.id
-        output = StringIO()
+        output = self.StringIO()
         c = self.pt_getContext()
         c.update(extra_context)