[Zope3-checkins] CVS: Zope3/src/zope/app/security/grants - metadirectives.py:1.1 configure.zcml:1.4 meta.zcml:1.3 metaconfigure.py:1.4

Stephan Richter srichter@cosmos.phy.tufts.edu
Sat, 2 Aug 2003 16:06:10 -0400


Update of /cvs-repository/Zope3/src/zope/app/security/grants
In directory cvs.zope.org:/tmp/cvs-serv31235/security/grants

Modified Files:
	configure.zcml meta.zcml metaconfigure.py 
Added Files:
	metadirectives.py 
Log Message:
Converted all security-related ZCML directives to the new way of doing 
things.

Note: The Permission id is now required to be an id, which means it must 
be a dotted name or a URI.

I wonder whether we should enforce the same for role and principal ids?!?
Comments?



=== Added File Zope3/src/zope/app/security/grants/metadirectives.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Grant Directive Schema

$Id: metadirectives.py,v 1.1 2003/08/02 20:05:36 srichter Exp $
"""
from zope.interface import Interface
from zope.schema import BytesLine, Id 

class IGrantDirective(Interface):
    """Grant Permissions to roles and principals and roles to principals."""

    principal = BytesLine(
        title=u"Principal",
        description=u"Specifies the Principal to be mapped.",
        required=False)

    permission = Id(
        title=u"Permission",
        description=u"Specifies the Permission to be mapped.",
        required=False)

    role = BytesLine(
        title=u"Role",
        description=u"Specifies the Role to be mapped.",
        required=False)


=== Zope3/src/zope/app/security/grants/configure.zcml 1.3 => 1.4 ===
--- Zope3/src/zope/app/security/grants/configure.zcml:1.3	Thu Dec 26 13:49:07 2002
+++ Zope3/src/zope/app/security/grants/configure.zcml	Sat Aug  2 16:05:36 2003
@@ -1,38 +1,33 @@
-<zopeConfigure
-   xmlns='http://namespaces.zope.org/zope'
-   xmlns:browser='http://namespaces.zope.org/browser'
-   >
+<configure xmlns="http://namespaces.zope.org/zope">
 
   <content class=".permissionroles.PermissionRoles">
     <require
         permission="zope.Security"
         attributes="roles rolesInfo"
-        interface="zope.app.interfaces.security.IRegisteredObject" 
-        />
-    </content>
+        interface="zope.app.interfaces.security.IRegisteredObject" />
+  </content>
 
   <content class="zope.app.security.grants.rolepermission.RolePermissions">
     <require
         permission="zope.Security"
         attributes="permissions permissionsInfo"
-        interface="zope.app.interfaces.security.IRegisteredObject" 
-        />
+        interface="zope.app.interfaces.security.IRegisteredObject" />
     </content>
 
-  <adapter factory=".rolepermission.AnnotationRolePermissionManager"
-           provides="zope.app.interfaces.security.IRolePermissionManager"
-           for="zope.app.interfaces.annotation.IAnnotatable" 
-           />
-
-  <adapter factory=".principalrole.AnnotationPrincipalRoleManager"
-           provides="zope.app.interfaces.security.IPrincipalRoleManager"
-           for="zope.app.interfaces.annotation.IAnnotatable" 
-           />
-
-  <adapter factory=".principalpermission.AnnotationPrincipalPermissionManager"
-           provides="zope.app.interfaces.security.IPrincipalPermissionManager"
-           for="zope.app.interfaces.annotation.IAnnotatable" 
-           />
+  <adapter 
+      factory=".rolepermission.AnnotationRolePermissionManager"
+      provides="zope.app.interfaces.security.IRolePermissionManager"
+      for="zope.app.interfaces.annotation.IAnnotatable" />
+
+  <adapter 
+      factory=".principalrole.AnnotationPrincipalRoleManager"
+      provides="zope.app.interfaces.security.IPrincipalRoleManager"
+      for="zope.app.interfaces.annotation.IAnnotatable" />
+
+  <adapter 
+      factory=".principalpermission.AnnotationPrincipalPermissionManager"
+      provides="zope.app.interfaces.security.IPrincipalPermissionManager"
+      for="zope.app.interfaces.annotation.IAnnotatable" />
 
-</zopeConfigure>
+</configure>
 


=== Zope3/src/zope/app/security/grants/meta.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/app/security/grants/meta.zcml:1.2	Wed Dec 25 09:13:16 2002
+++ Zope3/src/zope/app/security/grants/meta.zcml	Sat Aug  2 16:05:36 2003
@@ -1,10 +1,11 @@
-<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
+<configure 
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:meta="http://namespaces.zope.org/meta">
 
-  <directives namespace="http://namespaces.zope.org/zope">
+  <meta:directive 
+      namespace="http://namespaces.zope.org/zope"
+      name="grant" 
+      schema=".metadirectives.IGrantDirective"
+      handler=".metaconfigure.grant" />
 
-    <directive name="grant" attributes="principal permission role"
-       handler="zope.app.security.grants.metaconfigure.grant" />
-
-  </directives>
-
-</zopeConfigure>
+</configure>


=== Zope3/src/zope/app/security/grants/metaconfigure.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/security/grants/metaconfigure.py:1.3	Thu Dec 26 13:49:07 2002
+++ Zope3/src/zope/app/security/grants/metaconfigure.py	Sat Aug  2 16:05:36 2003
@@ -36,28 +36,20 @@
 
     if principal:
         if role:
-            return [
-                Action(
+            _context.action(
                 discriminator = ('grantRoleToPrincipal', role, principal),
                 callable = principal_role_mgr.assignRoleToPrincipal,
-                args = (role, principal),
-                )
-                ]
+                args = (role, principal) )
+
         if permission:
-            return [
-                Action(
+            _context.action(
                 discriminator = ('grantPermissionToPrincipal',
                                  permission,
                                  principal),
                 callable = principal_perm_mgr.grantPermissionToPrincipal,
-                args = (permission, principal),
-                )
-                ]
+                args = (permission, principal) )
     else:
-        return [
-            Action(
+        _context.action(
             discriminator = ('grantPermissionToRole', permission, role),
             callable = role_perm_mgr.grantPermissionToRole,
-            args = (permission, role),
-            )
-            ]
+            args = (permission, role) )