[Zope-Checkins] CVS: Zope27/lib/python/TAL - TALInterpreter.py:1.68.26.2

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


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

Modified Files:
      Tag: Zope-2_7-development-branch
	TALInterpreter.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/TAL/TALInterpreter.py 1.68.26.1 => 1.68.26.2 ===
--- Zope27/lib/python/TAL/TALInterpreter.py:1.68.26.1	Tue Jul 30 16:12:52 2002
+++ Zope27/lib/python/TAL/TALInterpreter.py	Sun Sep  8 22:04:52 2002
@@ -116,6 +116,11 @@
         self.i18nInterpolate = i18nInterpolate
         self.i18nContext = TranslationContext()
 
+    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 saveState(self):
         return (self.position, self.col, self.stream,
                 self.scopeLevel, self.level, self.i18nContext)
@@ -347,7 +352,7 @@
 
     def no_tag(self, start, program):
         state = self.saveState()
-        self.stream = stream = StringIO()
+        self.stream = stream = self.StringIO()
         self._stream_write = stream.write
         self.interpret(start)
         self.restoreOutputState(state)
@@ -474,7 +479,7 @@
             # evaluate the mini-program to get the value of the variable.
             state = self.saveState()
             try:
-                tmpstream = StringIO()
+                tmpstream = self.StringIO()
                 self.interpret(program, tmpstream)
                 value = normalize(tmpstream.getvalue())
             finally:
@@ -509,7 +514,7 @@
         #
         # Use a temporary stream to capture the interpretation of the
         # subnodes, which should /not/ go to the output stream.
-        tmpstream = StringIO()
+        tmpstream = self.StringIO()
         self.interpret(stuff[1], tmpstream)
         # We only care about the evaluated contents if we need an implicit
         # message id.  All other useful information will be in the i18ndict on
@@ -687,7 +692,7 @@
 
     def do_onError_tal(self, (block, handler)):
         state = self.saveState()
-        self.stream = stream = StringIO()
+        self.stream = stream = self.StringIO()
         self._stream_write = stream.write
         try:
             self.interpret(block)