[CMF-checkins] CVS: Products/CMFCore - FSObject.py:1.21

Jens Vagelpohl jens at dataflake.org
Wed May 4 15:52:44 EDT 2005


Update of /cvs-repository/Products/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv28632/CMFCore

Modified Files:
	FSObject.py 
Log Message:
- When customizing filesystem objects in the skins tool, some
  security-related settings were not transferred to the customized
  object, namely proxy roles and permission settings.
  (http://www.zope.org/Collectors/CMF/351)


=== Products/CMFCore/FSObject.py 1.20 => 1.21 ===
--- Products/CMFCore/FSObject.py:1.20	Sat Dec  4 17:05:18 2004
+++ Products/CMFCore/FSObject.py	Wed May  4 15:52:13 2005
@@ -20,7 +20,9 @@
 import Globals
 from AccessControl import ClassSecurityInfo
 from AccessControl.Role import RoleManager
+from AccessControl.Permission import Permission
 from Acquisition import Implicit
+from Acquisition import aq_base
 from OFS.Cache import Cacheable
 from OFS.SimpleItem import Item
 from DateTime import DateTime
@@ -85,6 +87,25 @@
         if ( cachemgr_id and 
              getattr(obj, 'ZCacheable_setManagerId', None) is not None ):
             obj.ZCacheable_setManagerId(cachemgr_id)
+
+        # If there are proxy roles we preserve them
+        proxy_roles = getattr(aq_base(self), '_proxy_roles', None)
+        if proxy_roles is not None and isinstance(proxy_roles, tuple):
+            obj._proxy_roles = tuple(self._proxy_roles)
+
+        # Also, preserve any permission settings that might have come
+        # from a metadata file or from fiddling in the ZMI
+        old_info = [x[:2] for x in self.ac_inherited_permissions(1)]
+        for old_perm, value in old_info:
+            p = Permission(old_perm, value, self)
+            acquired = int(isinstance(p.getRoles(default=[]), list))
+            rop_info = self.rolesOfPermission(old_perm)
+            roles = [x['name'] for x in rop_info if x['selected'] != '']
+            try:
+                obj.manage_permission(old_perm, roles=roles, acquire=acquired)
+            except ValueError:
+                # The permission was invalid, never mind
+                pass
 
         id = obj.getId()
         fpath = tuple( folder_path.split('/') )



More information about the CMF-checkins mailing list