[ZPT] CVS: Packages/TAL - TALInterpreter.py:1.35

guido@digicool.com guido@digicool.com
Mon, 9 Apr 2001 22:12:13 -0400 (EDT)


Update of /cvs-repository/Packages/TAL
In directory korak:/tmp/cvs-serv25025

Modified Files:
	TALInterpreter.py 
Log Message:
When doing macro expansion, add two tests:

- that the TALcode version of the macro is the same as that of the
  main program;

- that the mode (html or xml) of the macro is the same as that of the
  main program.

If either of these tests fails, raise METALError().



--- Updated File TALInterpreter.py in package Packages/TAL --
--- TALInterpreter.py	2001/04/09 22:51:34	1.34
+++ TALInterpreter.py	2001/04/10 02:12:12	1.35
@@ -96,7 +96,8 @@
 except ImportError:
     from StringIO import StringIO
 
-from TALDefs import quote, TAL_VERSION
+from TALDefs import quote, TAL_VERSION, METALError
+from TALDefs import isCurrentVersion, getProgramVersion, getProgramMode
 from TALGenerator import TALGenerator
 
 BOOLEAN_HTML_ATTRS = [
@@ -377,6 +378,14 @@
             self.interpret(block)
             return
         macro = self.engine.evaluateMacro(macroExpr)
+        if not isCurrentVersion(macro):
+            raise METALError("macro %s has incompatible version %s" %
+                             (`macroName`, `getProgramVersion(macro)`),
+                             self.position)
+        mode = getProgramMode(macro)
+        if mode != (self.html and "html" or "xml"):
+            raise METALError("macro %s has incompatible mode %s" %
+                             (`macroName`, `mode`), self.position)
         save = self.slots, self.currentMacro
         self.slots = compiledSlots
         self.currentMacro = macroName