[Zope-Checkins] CVS: Zope/lib/python/AccessControl - SimpleObjectPolicies.py:1.12.6.3

Tres Seaver tseaver at zope.com
Mon Jan 26 14:55:50 EST 2004


Update of /cvs-repository/Zope/lib/python/AccessControl
In directory cvs.zope.org:/tmp/cvs-serv16275/lib/python/AccessControl

Modified Files:
      Tag: Zope-2_6-branch
	SimpleObjectPolicies.py 
Log Message:
 - Make *BTreeItems accessible to untrusted code.


=== Zope/lib/python/AccessControl/SimpleObjectPolicies.py 1.12.6.2 => 1.12.6.3 ===
--- Zope/lib/python/AccessControl/SimpleObjectPolicies.py:1.12.6.2	Mon Jan 19 13:54:10 2004
+++ Zope/lib/python/AccessControl/SimpleObjectPolicies.py	Mon Jan 26 14:55:49 2004
@@ -71,7 +71,7 @@
 
 Containers=ContainerAssertions.get
 
-from types import IntType, DictType, TypeType
+from types import IntType, DictType, TypeType, ListType
 def allow_type(Type, allowed=1):
     """Allow a type and all of its methods and attributes to be used from
     restricted code.  The argument Type must be a type."""
@@ -82,3 +82,34 @@
     if not (isinstance(allowed, IntType) or isinstance(allowed, DictType)):
         raise ValueError, "The 'allowed' argument must be an int or dict."
     ContainerAssertions[Type] = allowed
+
+#
+#   WAAAA!
+#
+from BTrees.OOBTree import OOBTree, OOBucket, OOSet
+from BTrees.OIBTree import OIBTree, OIBucket, OISet
+from BTrees.IOBTree import IOBTree, IOBucket, IOSet
+from BTrees.IIBTree import IIBTree, IIBucket, IISet
+
+for tree_type, has_values in [(OOBTree, 1),
+                              (OOBucket, 1),
+                              (OOSet, 0),
+                              (OIBTree, 1),
+                              (OIBucket, 1),
+                              (OISet, 0),
+                              (IOBTree, 1),
+                              (IOBucket, 1),
+                              (IOSet, 0),
+                              (IIBTree, 1),
+                              (IIBucket, 1),
+                              (IISet, 0),
+                             ]:
+    tree = tree_type()
+    key_type = type(tree.keys())
+
+    if key_type is not ListType: # lists have their own declarations
+        allow_type(key_type)
+
+    if has_values:
+        assert key_type is type(tree.values())
+        assert key_type is type(tree.items())




More information about the Zope-Checkins mailing list