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

Stephan Richter srichter@cosmos.phy.tufts.edu
Sat Aug 2 21:06:16 EDT 2003


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

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/registries/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.
#
##############################################################################
"""Renderer configuration code

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

class IBaseDefineDirective(Interface):
    """Define a new security object."""
    
    id = TextLine(
        title=u"Id",
        description=u"Id as which this object will be known and used.",
        required=True)

    title = TextLine(
        title=u"Title",
        description=u"Provides a title for the object.",
        required=True)

    description = Text(
        title=u"Title",
        description=u"Provides a description for the object.",
        required=False)


class IDefinePermissionDirective(IBaseDefineDirective):
    """Define a new permission."""

    id = Id(
        title=u"Id",
        description=u"Id as which this permission will be known and used.",
        required=True)

class IDefineRoleDirective(IBaseDefineDirective):
    """Define a new role."""

class IDefinePrincipalDirective(IBaseDefineDirective):
    """Define a new principal."""

    login = TextLine(
        title=u"Username/Login",
        description=u"Specifies the Principal's Username/Login.",
        required=True)

    password = TextLine(
        title=u"Password",
        description=u"Specifies the Principal's Password.",
        required=True)

class IDefineUnauthenticatedPrincipalDirective(IBaseDefineDirective):
    """Define a new unauthenticated principal."""



=== Zope3/src/zope/app/security/registries/configure.zcml 1.3 => 1.4 ===
--- Zope3/src/zope/app/security/registries/configure.zcml:1.3	Mon Feb  3 15:20:10 2003
+++ Zope3/src/zope/app/security/registries/configure.zcml	Sat Aug  2 16:05:39 2003
@@ -1,12 +1,11 @@
-<zopeConfigure
-   xmlns='http://namespaces.zope.org/zope'
-   xmlns:browser='http://namespaces.zope.org/browser'
-   package="zope.app.security"
->
+<configure
+   xmlns="http://namespaces.zope.org/zope"
+   package="zope.app.security">
 
   <serviceType
       id="Roles" 
       interface="zope.app.interfaces.security.IRoleService" />
+
   <service
       serviceType="Roles" 
       component=".registries.roleregistry.roleRegistry" />
@@ -14,28 +13,26 @@
   <serviceType
       id="Permissions" 
       interface="zope.app.interfaces.security.IPermissionService" />
+
   <service
       serviceType="Permissions" 
-      component=".registries.permissionregistry.permissionRegistry" 
-      />
+      component=".registries.permissionregistry.permissionRegistry" />
 
   <serviceType
       id="Authentication" 
       interface="zope.app.interfaces.security.IAuthenticationService" />
+
   <service
       serviceType="Authentication" 
-      component=".registries.principalregistry.principalRegistry" 
-      />
+      component=".registries.principalregistry.principalRegistry" />
 
   <!-- protect Roles and Permissions -->
   <content class=".registries.roleregistry.Role">
-    <allow
-        interface="zope.app.interfaces.security.IRegisteredObject" />
+    <allow interface="zope.app.interfaces.security.IRegisteredObject" />
   </content>
 
   <content class=".registries.permissionregistry.Permission">
-    <allow
-        interface="zope.app.interfaces.security.IRegisteredObject" />
+    <allow interface="zope.app.interfaces.security.IRegisteredObject" />
   </content>
 
   <content class=".registries.principalregistry.Principal">
@@ -43,5 +40,5 @@
   </content>
 
   
-</zopeConfigure>
+</configure>
 


=== Zope3/src/zope/app/security/registries/meta.zcml 1.3 => 1.4 ===
--- Zope3/src/zope/app/security/registries/meta.zcml:1.3	Mon Jul 28 18:21:51 2003
+++ Zope3/src/zope/app/security/registries/meta.zcml	Sat Aug  2 16:05:39 2003
@@ -1,22 +1,29 @@
-<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
+<configure 
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:meta="http://namespaces.zope.org/meta">
 
-  <!-- zope.app.security -->
-  <directives namespace="http://namespaces.zope.org/zope">
-    <directive
-       name="permission"
-       attributes="id title description"
-       handler="zope.app.security.registries.metaconfigure.definePermission" />
-    <directive 
-       name="role"
-       attributes="id title description"
-       handler="zope.app.security.registries.metaconfigure.defineRole" />
-    <directive 
-       name="principal" 
-       attributes="id title description login password"
-       handler="zope.app.security.registries.metaconfigure.principal" />
-    <directive name="unauthenticatedPrincipal" 
-               attributes="id title description"
-       handler=".metaconfigure.unauthenticatedPrincipal" />
-  </directives>
+  <meta:directive
+      namespace="http://namespaces.zope.org/zope"
+      name="permission"
+      schema=".metadirectives.IDefinePermissionDirective"
+      handler=".metaconfigure.definePermission" />
 
-</zopeConfigure>
+  <meta:directive 
+      namespace="http://namespaces.zope.org/zope"
+      name="role"
+      schema=".metadirectives.IDefineRoleDirective"
+      handler=".metaconfigure.defineRole" />
+
+  <meta:directive 
+      namespace="http://namespaces.zope.org/zope"
+      name="principal" 
+      schema=".metadirectives.IDefinePrincipalDirective"
+      handler=".metaconfigure.principal" />
+
+  <meta:directive 
+      namespace="http://namespaces.zope.org/zope"
+      name="unauthenticatedPrincipal" 
+      schema=".metadirectives.IDefineUnauthenticatedPrincipalDirective"
+      handler=".metaconfigure.unauthenticatedPrincipal" />
+
+</configure>


=== Zope3/src/zope/app/security/registries/metaconfigure.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/security/registries/metaconfigure.py:1.4	Thu May  1 15:35:32 2003
+++ Zope3/src/zope/app/security/registries/metaconfigure.py	Sat Aug  2 16:05:39 2003
@@ -19,40 +19,27 @@
      permissionRegistry as perm_reg
 from zope.app.security.registries.roleregistry import roleRegistry as role_reg
 from zope.app.security.registries.principalregistry import principalRegistry
-from zope.configuration.action import Action
 
 def definePermission(_context, id, title, description=''):
-    return [
-        Action(
-            discriminator = ('definePermission', id),
-            callable = perm_reg.definePermission,
-            args = (id, title, description),
-            )
-        ]
+    _context.action(
+        discriminator = ('definePermission', id),
+        callable = perm_reg.definePermission,
+        args = (id, title, description) )
 
 def defineRole(_context, id, title, description=''):
-    return [
-        Action(
+    _context.action(
             discriminator = ('defineRole', id),
             callable = role_reg.defineRole,
-            args = (id, title, description),
-            )
-        ]
+            args = (id, title, description) )
 
 def principal(_context, id, title, login, password, description=''):
-    return [
-        Action(
-            discriminator = ('principal', id),
-            callable = principalRegistry.definePrincipal,
-            args = (id, title, description, login, password),
-            )
-        ]
+    _context.action(
+        discriminator = ('principal', id),
+        callable = principalRegistry.definePrincipal,
+        args = (id, title, description, login, password) )
 
 def unauthenticatedPrincipal(_context, id, title, description=''):
-    return [
-        Action(
-            discriminator = 'unauthenticatedPrincipal',
-            callable = principalRegistry.defineDefaultPrincipal,
-            args = (id, title, description),
-            )
-        ]
+    _context.action(
+        discriminator = 'unauthenticatedPrincipal',
+        callable = principalRegistry.defineDefaultPrincipal,
+        args = (id, title, description) )





More information about the Zope3-Checkins mailing list