[Zope-Checkins] CVS: Zope3/lib/python/Zope/TAL - TALInterpreter.py:1.79.2.2

Barry Warsaw barry@wooz.org
Wed, 26 Jun 2002 11:45:38 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/TAL
In directory cvs.zope.org:/tmp/cvs-serv16602

Modified Files:
      Tag: tal-i18n-refactor-branch
	TALInterpreter.py 
Log Message:
do_i18nVariable(): The order of the mini-program and the expression
has changed, as is the determinant of which to use for the value of
the variable.  This fixes i18n:name + (explicit) tal:replace.


=== Zope3/lib/python/Zope/TAL/TALInterpreter.py 1.79.2.1 => 1.79.2.2 ===
 
     def do_i18nVariable(self, stuff):
-        varname = stuff[0]
-        if isinstance(stuff[1], ListType):
+        varname, program, expression = stuff
+        if expression is None:
             # The value is implicitly the contents of this tag, so we have to
-            # evaluate the mini-program
+            # evaluate the mini-program to get the value of the variable.
             state = self.saveState()
             try:
                 tmpstream = StringIO()
-                self.interpret(stuff[1], tmpstream)
+                self.interpret(program, tmpstream)
                 value = normalize(tmpstream.getvalue())
             finally:
                 self.restoreState(state)
         else:
             # Evaluate the value to be associated with the variable in the
             # i18n interpolation dictionary.
-            value = self.engine.evaluate(stuff[1])
+            value = self.engine.evaluate(expression)
         # Either the i18n:name tag is nested inside an i18n:translate in which
         # case the last item on the stack has the i18n dictionary and string
         # representation, or the i18n:name and i18n:translate attributes are