[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - ZopeSecurityPolicy.py:1.1.2.22

Steve Alexander steve@cat-box.net
Mon, 18 Mar 2002 16:44:41 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv6783/lib/python/Zope/App/Security

Modified Files:
      Tag: Zope-3x-branch
	ZopeSecurityPolicy.py 
Log Message:
More hacks... this time, to unwrap values before checking them against
primitive types, as isinstance() doesn't work with wrapped values.


=== Zope3/lib/python/Zope/App/Security/ZopeSecurityPolicy.py 1.1.2.21 => 1.1.2.22 ===
 from types import StringTypes, ListType, IntType, MethodType, NoneType
 
+# XXX: hack alert
+from Zope.ContextWrapper import getbaseobject
+
 getPermissionsForPrincipal = \
                 principalPermissionManager.getPermissionsForPrincipal
 getPermissionsForRole      = rolePermissionManager.getPermissionsForRole
@@ -93,11 +96,13 @@
             #      This is still a hack, and still incomplete, and just here
             #      to get the ZMI working.
             
-            if (isinstance(value, (ListType, StringTypes, IntType, NoneType))
+            
+            unwrapped_value = getbaseobject(value)
+            if (isinstance(unwrapped_value, (ListType, StringTypes, IntType, NoneType))
                 or 
                 getattr(value,'__allow_access_to_unprotected_subobjects__',0)):
                 permission = 'Zope.Public'
-            elif (isinstance(value, MethodType) and 
+            elif (isinstance(unwrapped_value, MethodType) and 
                   getattr(value.im_self,
                           '__allow_access_to_unprotected_subobjects__',
                           0)):