[ZPT] CVS: Zope27/lib/python/Products/PageTemplates - Expressions.py:1.35.18.6

Fred L. Drake, Jr. fdrake@acm.org
Tue, 17 Sep 2002 16:51:31 -0400


Update of /cvs-repository/Zope27/lib/python/Products/PageTemplates
In directory cvs.zope.org:/tmp/cvs-serv15250

Modified Files:
      Tag: Zope-2_7-development-branch
	Expressions.py 
Log Message:
restrictedTraverse():  Minor cleanups:
    - Delay creation of REQUEST slightly.
    - Set __traceback_info__ only once, outside of the loop, since it
      is always set to the same value.
    - Don't call the first argument self, since this isn't a method.
      We can avoid one local variable assignment by doing this.


=== Zope27/lib/python/Products/PageTemplates/Expressions.py 1.35.18.5 => 1.35.18.6 ===
--- Zope27/lib/python/Products/PageTemplates/Expressions.py:1.35.18.5	Tue Sep 17 16:05:00 2002
+++ Zope27/lib/python/Products/PageTemplates/Expressions.py	Tue Sep 17 16:51:30 2002
@@ -285,28 +285,27 @@
         return 'defer:%s' % `self._s`
 
 
-def restrictedTraverse(self, path, securityManager,
+def restrictedTraverse(object, path, securityManager,
                        get=getattr, has=hasattr, N=None, M=[],
                        TupleType=type(()) ):
 
-    REQUEST = {'path': path}
-    REQUEST['TraversalRequestNameStack'] = path = path[:] # Copy!
     if not path[0]:
         # If the path starts with an empty string, go to the root first.
-        self = self.getPhysicalRoot()
-        if not securityManager.validateValue(self):
+        object = object.getPhysicalRoot()
+        if not securityManager.validateValue(object):
             raise Unauthorized, name
         path.pop(0)
-        
+
+    REQUEST = {'path': path}
+    REQUEST['TraversalRequestNameStack'] = path = path[:] # Copy!
     path.reverse()
     validate = securityManager.validate
-    object = self
+    __traceback_info__ = REQUEST
     while path:
-        __traceback_info__ = REQUEST
         name = path.pop()
 
         if isinstance(name, TupleType):
-            object = apply(object, name)
+            object = object(*name)
             continue
 
         if name[0] == '_':
@@ -324,7 +323,7 @@
         t=get(object, '__bobo_traverse__', N)
         if t is not N:
             o=t(REQUEST, name)
-                    
+
             container = None
             if aq_base(o) is not o:
                 # The object is wrapped, so the acquisition