[ZPT] CVS: Releases/Zope/lib/python/Products/PageTemplates - Expressions.py:1.31 PathIterator.py:1.2

Evan Simpson evan@zope.com
Thu, 13 Dec 2001 15:18:52 -0500


Update of /cvs-repository/Releases/Zope/lib/python/Products/PageTemplates
In directory cvs.zope.org:/tmp/cvs-serv18549

Modified Files:
	Expressions.py PathIterator.py 
Log Message:
Fix first() and last() to work with Zope security, document them.


=== Releases/Zope/lib/python/Products/PageTemplates/Expressions.py 1.30 => 1.31 ===
 
 def restrictedTraverse(self, path, securityManager,
-                       get=getattr, has=hasattr, N=None, M=[]):
+                       get=getattr, has=hasattr, N=None, M=[],
+                       TupleType=type(()) ):
 
     REQUEST = {'path': path}
     REQUEST['TraversalRequestNameStack'] = path = path[:] # Copy!
@@ -289,6 +290,10 @@
     while path:
         __traceback_info__ = REQUEST
         name = path.pop()
+
+        if isinstance(name, TupleType):
+            object = apply(object, name)
+            continue
 
         if name[0] == '_':
             # Never allowed in a URL.


=== Releases/Zope/lib/python/Products/PageTemplates/PathIterator.py 1.1 => 1.2 ===
 import TALES
 from Expressions import restrictedTraverse, Undefs, getSecurityManager
+from string import split
 
 class Iterator(TALES.Iterator):
     def __bobo_traverse__(self, REQUEST, name):
         if name in ('first', 'last'):
             path = REQUEST['TraversalRequestNameStack']
             names = list(path)
-            del path[:]
             names.reverse()
-            return getattr(self, name)(names)
+            path[:] = [tuple(names)]
         return getattr(self, name)
-            
+
     def same_part(self, name, ob1, ob2):
         if name is None:
             return ob1 == ob2