[Zope3-checkins] CVS: Zope3/lib/python/Zope/DocumentTemplate - DT_Util.py:1.2

Shane Hathaway shane@cvs.zope.org
Fri, 19 Jul 2002 14:09:53 -0400


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

Modified Files:
	DT_Util.py 
Log Message:
Fixed DTML expression evaluation according to the way it is done in Zope 2.
The tests pass. ;-)


=== Zope3/lib/python/Zope/DocumentTemplate/DT_Util.py 1.1 => 1.2 ===
            '_': mapping}
         code = self.code
         for name in code.co_names:
-            __traceback_info__ = name
-            try:
-                d[name] = mapping.getitem(name,0)
-            except KeyError:
-                if name == '_getattr':
-                    d['__builtins__'] = globals
-                    exec compiled_getattr in d
+            if not d.has_key(name):
+                __traceback_info__ = name
+                try:
+                    d[name] = mapping.getitem(name, 0)
+                except KeyError:
+                    # Swallow KeyErrors since the expression
+                    # might not actually need the name.  If it
+                    # does need the name, a NameError will occur.
+                    pass
 
         return eval(code, {}, d)