[Zope-Checkins] SVN: Zope/branches/2.10/lib/python/Products/PageTemplates/ Merge from trunk:

Philipp von Weitershausen philikon at philikon.de
Thu Jun 1 16:28:05 EDT 2006


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

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

-=-
Modified: Zope/branches/2.10/lib/python/Products/PageTemplates/Expressions.py
===================================================================
--- Zope/branches/2.10/lib/python/Products/PageTemplates/Expressions.py	2006-06-01 20:26:48 UTC (rev 68451)
+++ Zope/branches/2.10/lib/python/Products/PageTemplates/Expressions.py	2006-06-01 20:28:04 UTC (rev 68452)
@@ -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/branches/2.10/lib/python/Products/PageTemplates/tests/testExpressions.py
===================================================================
--- Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testExpressions.py	2006-06-01 20:26:48 UTC (rev 68451)
+++ Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testExpressions.py	2006-06-01 20:28:04 UTC (rev 68452)
@@ -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
         """



More information about the Zope-Checkins mailing list