[Zope3-dev] More patches

Gustavo Niemeyer niemeyer at conectiva.com
Tue Sep 21 16:35:11 EDT 2004


> zope3-owner.patch
> - Patch implementing a suggested "Owner" role.

Here is a new version of this patch, which includes the owner
role support for children with their own grant info as well.

Btw, is this list interested in this kind of patch, or perhaps
there's a better way/place to submit them (.. or should I
just keep them to myself :-)?

-- 
Gustavo Niemeyer
http://niemeyer.net
-------------- next part --------------
Index: src/zope/app/securitypolicy/zopepolicy.py
===================================================================
--- src/zope/app/securitypolicy/zopepolicy.py	(revision 27642)
+++ src/zope/app/securitypolicy/zopepolicy.py	(working copy)
@@ -24,6 +24,8 @@
 from zope.security.interfaces import ISecurityPolicy
 from zope.security.proxy import removeSecurityProxy
 
+from zope.app.dublincore.interfaces import IZopeDublinCore
+
 from zope.app.security.settings import Allow, Deny
 
 from zope.app.securitypolicy.principalpermission \
@@ -189,12 +191,17 @@
             cache_principal_roles[principal] = roles
             return roles
             
-        roles = self.cached_principal_roles(
+        parentroles = roles = self.cached_principal_roles(
             removeSecurityProxy(getattr(parent, '__parent__', None)),
             principal)
+        dc = IZopeDublinCore(parent, None)
+        if dc and principal in dc.creators:
+            roles = roles.copy()
+            roles["zope.Owner"] = 1
         prinrole = IPrincipalRoleMap(parent, None)
         if prinrole:
-            roles = roles.copy()
+            if roles is parentroles:
+                roles = roles.copy()
             for role, setting in prinrole.getRolesForPrincipal(principal):
                 if setting is Allow:
                     roles[role] = 1
@@ -263,8 +270,12 @@
                 elif role in roles:
                     del roles[role]
 
+        dc = IZopeDublinCore(object, None)
+        creators = dc and dc.creators or ()
         for principal in principals.keys():
             proles = self.cached_principal_roles(parent, principal).copy()
+            if principal in creators:
+                proles["zope.Owner"] = 1
             for role, setting in grant_info.getRolesForPrincipal(principal):
                 if setting is Allow:
                     if role in roles:
Index: src/zope/app/securitypolicy/configure.zcml
===================================================================
--- src/zope/app/securitypolicy/configure.zcml	(revision 27642)
+++ src/zope/app/securitypolicy/configure.zcml	(working copy)
@@ -92,6 +92,8 @@
                  description="All users have this role implicitly" />
   <role id="zope.Manager" title="Site Manager" />
   <role id="zope.Member" title="Site Member" />
+  <role id="zope.Owner" title="Object Owner"
+                 description="Object owners" />
 
   <!-- Replace the following directive if you don't want public access -->
   <grant permission="zope.View"                  


More information about the Zope3-dev mailing list