[Zope-Checkins] CVS: Zope/lib/python/TAL - DummyEngine.py:1.29.18.2 TALGenerator.py:1.53.18.1 TALInterpreter.py:1.66.2.2

Shane Hathaway shane@cvs.zope.org
Mon, 4 Mar 2002 18:14:39 -0500


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

Modified Files:
      Tag: shane-better-tracebacks-branch
	DummyEngine.py TALGenerator.py TALInterpreter.py 
Log Message:
Added tracking of the source filename for TAL so that tracebacks can show a
filename along with the (line, column) pair.


=== Zope/lib/python/TAL/DummyEngine.py 1.29.18.1 => 1.29.18.2 ===
 
     position = None
+    source_file = None
 
     def __init__(self, macros=None):
         if macros is None:
@@ -43,6 +44,9 @@
 
     def getCompilerError(self):
         return CompilerError
+
+    def setSourceFile(self, source_file):
+        self.source_file = source_file
 
     def setPosition(self, position):
         self.position = position


=== Zope/lib/python/TAL/TALGenerator.py 1.53 => 1.53.18.1 ===
     inMacroUse = 0
     inMacroDef = 0
+    source_file = None
     
-    def __init__(self, expressionCompiler=None, xml=1):
+    def __init__(self, expressionCompiler=None, xml=1, source_file=None):
         if not expressionCompiler:
             from DummyEngine import DummyEngine
             expressionCompiler = DummyEngine()
@@ -40,6 +41,9 @@
         self.xml = xml
         self.emit("version", TAL_VERSION)
         self.emit("mode", xml and "xml" or "html")
+        if source_file is not None:
+            self.source_file = source_file
+            self.emit("setSourceFile", source_file)
 
     def getCode(self):
         assert not self.stack
@@ -438,6 +442,8 @@
                 self.pushProgram()
                 self.emit("version", TAL_VERSION)
                 self.emit("mode", self.xml and "xml" or "html")
+                if self.source_file is not None:
+                    self.emit("setSourceFile", self.source_file)
                 todo["defineMacro"] = defineMacro
                 self.inMacroDef = self.inMacroDef + 1
             if useMacro:


=== Zope/lib/python/TAL/TALInterpreter.py 1.66.2.1 => 1.66.2.2 ===
     bytecode_handlers["mode"] = do_mode
 
+    def do_setSourceFile(self, source_file):
+        self.engine.setSourceFile(source_file)
+    bytecode_handlers["setSourceFile"] = do_setSourceFile
+
     def do_setPosition(self, position):
         self.position = position
         self.engine.setPosition(position)