Log message for revision 72009: fixed code to allow Python's 'set' module
Changed: U Zope/trunk/doc/CHANGES.txt U Zope/trunk/lib/python/AccessControl/DTML.py U Zope/trunk/lib/python/AccessControl/ZopeGuards.py U Zope/trunk/lib/python/Products/PythonScripts/tests/testPythonScript.py U Zope/trunk/lib/python/RestrictedPython/Utilities.py -=- Modified: Zope/trunk/doc/CHANGES.txt =================================================================== --- Zope/trunk/doc/CHANGES.txt 2007-01-13 15:27:12 UTC (rev 72008) +++ Zope/trunk/doc/CHANGES.txt 2007-01-13 16:42:22 UTC (rev 72009) @@ -48,7 +48,7 @@ Features added - - PythonScripts: added 'Set' class to RestrictedPython (Collector #1918) + - PythonScripts: allow usage of Python's 'sets' module - added 'fast_listen' directive to http-server and webdav-source-server sections in etc/zope.conf in order to defer the opening of the sockets Modified: Zope/trunk/lib/python/AccessControl/DTML.py =================================================================== --- Zope/trunk/lib/python/AccessControl/DTML.py 2007-01-13 15:27:12 UTC (rev 72008) +++ Zope/trunk/lib/python/AccessControl/DTML.py 2007-01-13 16:42:22 UTC (rev 72009) @@ -15,7 +15,7 @@ $Id$ """ from DocumentTemplate import DT_Util -import SecurityManagement, string, math, random +import SecurityManagement, string, math, random, sets import DocumentTemplate.sequence from ZopeGuards import safe_builtins @@ -28,7 +28,9 @@ string.__allow_access_to_unprotected_subobjects__=1 math.__allow_access_to_unprotected_subobjects__=1 random.__allow_access_to_unprotected_subobjects__=1 +sets.__allow_access_to_unprotected_subobjects__=1 + DocumentTemplate.sequence.__allow_access_to_unprotected_subobjects__=1 # Add security testing capabilities Modified: Zope/trunk/lib/python/AccessControl/ZopeGuards.py =================================================================== --- Zope/trunk/lib/python/AccessControl/ZopeGuards.py 2007-01-13 15:27:12 UTC (rev 72008) +++ Zope/trunk/lib/python/AccessControl/ZopeGuards.py 2007-01-13 16:42:22 UTC (rev 72009) @@ -295,6 +295,7 @@ return list.sorted(iterable, cmp=None, key=None, reverse=False) safe_builtins['list'] = GuardedListType() + class GuardedDictType: def __call__(self, *args, **kwargs): return dict(*args, **kwargs) @@ -303,6 +304,7 @@ return dict.fromkeys(S,v) safe_builtins['dict'] = GuardedDictType() + def guarded_enumerate(seq): return NullIter(enumerate(guarded_iter(seq))) safe_builtins['enumerate'] = guarded_enumerate Modified: Zope/trunk/lib/python/Products/PythonScripts/tests/testPythonScript.py =================================================================== --- Zope/trunk/lib/python/Products/PythonScripts/tests/testPythonScript.py 2007-01-13 15:27:12 UTC (rev 72008) +++ Zope/trunk/lib/python/Products/PythonScripts/tests/testPythonScript.py 2007-01-13 16:42:22 UTC (rev 72009) @@ -206,7 +206,7 @@ self.assertEqual(f.get_size(), len(f.read())) def testSet(self): - res = self._newPS('return len(Set([1,2,3]))')() + res = self._newPS('from sets import Set; return len(Set([1,2,3]))')() self.assertEqual(res, 3) def testDateTime(self): Modified: Zope/trunk/lib/python/RestrictedPython/Utilities.py =================================================================== --- Zope/trunk/lib/python/RestrictedPython/Utilities.py 2007-01-13 15:27:12 UTC (rev 72008) +++ Zope/trunk/lib/python/RestrictedPython/Utilities.py 2007-01-13 16:42:22 UTC (rev 72009) @@ -16,7 +16,7 @@ import string, math, random import DocumentTemplate.sequence from DateTime.DateTime import DateTime -from sets import Set +import sets utility_builtins = {} @@ -25,7 +25,7 @@ utility_builtins['random'] = random utility_builtins['sequence'] = DocumentTemplate.sequence utility_builtins['DateTime'] = DateTime -utility_builtins['Set'] = Set +utility_builtins['sets'] = sets def same_type(arg1, *args): _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins