[Zope-Checkins] CVS: Zope2 - DT_Util.py:1.72.18.2

shane@digicool.com shane@digicool.com
Fri, 20 Apr 2001 13:27:38 -0400 (EDT)


Update of /cvs-repository/Zope2/lib/python/DocumentTemplate
In directory korak:/tmp/cvs-serv20802

Modified Files:
      Tag: RestrictedPythonBranch
	DT_Util.py 
Log Message:
Works with revisions to RestrictionMutator



--- Updated File DT_Util.py in package Zope2 --
--- DT_Util.py	2001/04/19 22:52:47	1.72.18.1
+++ DT_Util.py	2001/04/20 17:27:38	1.72.18.2
@@ -312,11 +312,11 @@
 class DTMLGuard:
     _md = None
 
-    def __init__(self, ob):
+    def __init__(self, md, ob):
         self._ob = ob
 
     def __getattr__(self, name):
-        if name[:1]!='_':
+        if name[:1]!='_':  # Shouldn't be necessary to check for _
             inst = self._ob
             # Try to get the attribute normally so that we don't
             # accidentally acquire when we shouldn't.
@@ -372,12 +372,12 @@
 class Eval(RestrictedEval):
 
     def eval(self, mapping):
+        d = {'_': mapping}
         # Create a temporary subclass of DTMLGuard.
-        d = self.globals.copy()
         class Guard (DTMLGuard): pass
         Guard._md = mapping
-        d['_guard'] = Guard
-        d['_'] = mapping
+        globals = self.globals.copy()
+        globals['_guard'] = Guard
         code = self.code
         for name in self.used:
             __traceback_info__ = name
@@ -387,11 +387,10 @@
                 # might not actually need the name.  If it
                 # does need the name, a NameError will occur.
                 pass
+        return eval(code, globals, d)
 
-        #print 'eval', str(self)
-        #for k in dir(code):
-        #    print '%s: %s' % (k, repr(getattr(code, k)))
-        return eval(code, d)
+    def __call__(self, *args, **kw):
+        raise 'NotImplemented', 'Ignorant Digital Creations developer error'
 
 
 def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):