Log message for revision 68451:
  Allow access to ZopeIterator/PathIterator API from restricted Python
  (e.g. python expressions)
  

Changed:
  U   Zope/trunk/lib/python/Products/PageTemplates/Expressions.py
  U   Zope/trunk/lib/python/Products/PageTemplates/tests/testExpressions.py

-=-
Modified: Zope/trunk/lib/python/Products/PageTemplates/Expressions.py
===================================================================
--- Zope/trunk/lib/python/Products/PageTemplates/Expressions.py 2006-06-01 
19:56:09 UTC (rev 68450)
+++ Zope/trunk/lib/python/Products/PageTemplates/Expressions.py 2006-06-01 
20:26:48 UTC (rev 68451)
@@ -152,6 +152,10 @@
 
 class ZopeIterator(Iterator):
 
+    # allow iterator API to be accessed from (restricted) Python TALES
+    # expressions
+    __allow_access_to_unprotected_subobjects__ = True
+
     # The things below used to be attributes in
     # ZTUtils.Iterator.Iterator, however in zope.tales.tales.Iterator
     # they're methods.  We need BBB on the Python level so we redefine

Modified: Zope/trunk/lib/python/Products/PageTemplates/tests/testExpressions.py
===================================================================
--- Zope/trunk/lib/python/Products/PageTemplates/tests/testExpressions.py       
2006-06-01 19:56:09 UTC (rev 68450)
+++ Zope/trunk/lib/python/Products/PageTemplates/tests/testExpressions.py       
2006-06-01 20:26:48 UTC (rev 68451)
@@ -69,6 +69,14 @@
         assert ec.evaluate('x | string:$one') == '1'
         assert ec.evaluate('x | not:exists:x')
 
+    def testIteratorZRPythonExpr(self):
+        '''Test access to iterator functions from Python expressions'''
+        ec = self.ec
+        ec.beginScope()
+        ec.setRepeat('loop', "python:[1,2,3]")
+        assert ec.evaluate("python:repeat['loop'].even()")
+        ec.endScope()
+
     def testWrappers(self):
         """Test if defer and lazy are returning their wrappers
         """

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to