[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/ Move
some elementary security directives to zope.security.
Philipp von Weitershausen
philikon at philikon.de
Wed Apr 12 19:37:36 EDT 2006
Log message for revision 66923:
Move some elementary security directives to zope.security.
Changed:
U Zope3/branches/jim-adapter/src/zope/app/security/meta.zcml
U Zope3/branches/jim-adapter/src/zope/app/security/metaconfigure.py
U Zope3/branches/jim-adapter/src/zope/app/security/metadirectives.py
U Zope3/branches/jim-adapter/src/zope/app/securitypolicy/metadirectives.py
A Zope3/branches/jim-adapter/src/zope/security/meta.zcml
U Zope3/branches/jim-adapter/src/zope/security/zcml.py
-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/security/meta.zcml
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/security/meta.zcml 2006-04-12 23:28:07 UTC (rev 66922)
+++ Zope3/branches/jim-adapter/src/zope/app/security/meta.zcml 2006-04-12 23:37:35 UTC (rev 66923)
@@ -2,11 +2,7 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:meta="http://namespaces.zope.org/meta">
- <meta:directive
- namespace="http://namespaces.zope.org/zope"
- name="permission"
- schema=".metadirectives.IDefinePermissionDirective"
- handler=".metaconfigure.definePermission" />
+ <include package="zope.security" file="meta.zcml" />
<meta:directive
namespace="http://namespaces.zope.org/zope"
@@ -38,13 +34,6 @@
schema=".metadirectives.IDefineEverybodyGroupDirective"
handler=".metaconfigure.everybodyGroup" />
- <meta:directive
- name="securityPolicy"
- namespace="http://namespaces.zope.org/zope"
- schema=".metadirectives.ISecurityPolicyDirective"
- handler=".metaconfigure.securityPolicy"
- />
-
<meta:groupingDirective
name="module"
namespace="http://namespaces.zope.org/zope"
@@ -63,10 +52,4 @@
schema=".metadirectives.IRequire"
handler=".metaconfigure.require" />
- <meta:directive
- name="redefinePermission"
- namespace="http://namespaces.zope.org/meta"
- schema=".metadirectives.IRedefinePermission"
- handler=".metaconfigure.redefinePermission" />
-
</configure>
Modified: Zope3/branches/jim-adapter/src/zope/app/security/metaconfigure.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/security/metaconfigure.py 2006-04-12 23:28:07 UTC (rev 66922)
+++ Zope3/branches/jim-adapter/src/zope/app/security/metaconfigure.py 2006-04-12 23:37:35 UTC (rev 66923)
@@ -19,23 +19,11 @@
from zope.component.zcml import utility
from zope.security.checker import moduleChecker, Checker, defineChecker
from zope.security.checker import CheckerPublic
-from zope.security.management import setSecurityPolicy
-from zope.security.interfaces import IPermission
-from zope.security.permission import Permission
from zope.app.security import principalregistry
from zope.app.security import interfaces
-def securityPolicy(_context, component):
-
- _context.action(
- discriminator = 'defaultPolicy',
- callable = setSecurityPolicy,
- args = (component,) )
-
-
-
def protectModule(module, name, permission):
"""Set up a module checker to require a permission to access a name
@@ -89,12 +77,6 @@
args = (context.module, name, permission),
)
-
-def definePermission(_context, id, title, description=''):
- permission = Permission(id, title, description)
- utility(_context, IPermission, permission, name=id)
-
-
def _principal():
group = component.queryUtility(interfaces.IAuthenticatedGroup)
if group is not None:
@@ -200,13 +182,3 @@
callable = principalregistry.principalRegistry.registerGroup,
args = (principal, ),
)
-
-
-def redefinePermission(_context, from_, to):
- _context = _context.context
-
- # check if context has any permission mappings yet
- if not hasattr(_context, 'permission_mapping'):
- _context.permission_mapping={}
-
- _context.permission_mapping[from_] = to
Modified: Zope3/branches/jim-adapter/src/zope/app/security/metadirectives.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/security/metadirectives.py 2006-04-12 23:28:07 UTC (rev 66922)
+++ Zope3/branches/jim-adapter/src/zope/app/security/metadirectives.py 2006-04-12 23:37:35 UTC (rev 66923)
@@ -17,20 +17,22 @@
"""
from zope.interface import Interface
from zope.configuration.fields import GlobalObject, GlobalInterface
-from zope.configuration.fields import Tokens, PythonIdentifier, MessageID
+from zope.configuration.fields import Tokens, PythonIdentifier
from zope.schema import InterfaceField, Id, TextLine
from zope.security.zcml import Permission
+##############################################################################
+# BBB 2006/04/03 -- to be removed after 12 months
-class ISecurityPolicyDirective(Interface):
- """Defines the security policy that will be used for Zope."""
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "It has been renamed to zope.security.zcml.IPermissionDirective. "
+ "This reference will be gone in Zope 3.5",
+ IBaseDefineDirective = 'zope.security.zcml:IPermissionDirective'
+ )
- component = GlobalObject(
- title=u"Component",
- description=u"Pointer to the object that will handle the security.",
- required=True)
+##############################################################################
-
class IModule(Interface):
"""Group security declarations about a module"""
@@ -75,29 +77,6 @@
title=u"Permission ID",
description=u"The id of the permission to require.")
-
-class IBaseDefineDirective(Interface):
- """Define a new security object."""
-
- id = Id(
- title=u"Id",
- description=u"Id as which this object will be known and used.",
- required=True)
-
- title = MessageID(
- title=u"Title",
- description=u"Provides a title for the object.",
- required=True)
-
- description = MessageID(
- title=u"Description",
- description=u"Provides a description for the object.",
- required=False)
-
-
-class IDefinePermissionDirective(IBaseDefineDirective):
- """Define a new permission."""
-
class IBasePrincipalDirective(Interface):
"""Base interface for principal definition directives."""
@@ -147,16 +126,3 @@
class IDefineEverybodyGroupDirective(IBasePrincipalDirective):
"""Define the everybody group."""
-
-class IRedefinePermission(Interface):
- """Define a permission to replace another permission."""
-
- from_ = Permission(
- title=u"Original permission",
- description=u"Original permission id to redefine.",
- required=True)
-
- to = Permission(
- title=u"Substituted permission",
- description=u"Substituted permission id.",
- required=True)
Modified: Zope3/branches/jim-adapter/src/zope/app/securitypolicy/metadirectives.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/securitypolicy/metadirectives.py 2006-04-12 23:28:07 UTC (rev 66922)
+++ Zope3/branches/jim-adapter/src/zope/app/securitypolicy/metadirectives.py 2006-04-12 23:37:35 UTC (rev 66923)
@@ -17,8 +17,7 @@
"""
from zope.interface import Interface
from zope.schema import Id
-from zope.security.zcml import Permission
-from zope.app.security.metadirectives import IBaseDefineDirective
+from zope.security.zcml import Permission, IPermissionDirective
class IGrantAllDirective(Interface):
"""Grant Permissions to roles and principals and roles to principals."""
@@ -41,6 +40,6 @@
description=u"Specifies the Permission to be mapped.",
required=False)
-class IDefineRoleDirective(IBaseDefineDirective):
+class IDefineRoleDirective(IPermissionDirective):
"""Define a new role."""
Added: Zope3/branches/jim-adapter/src/zope/security/meta.zcml
===================================================================
--- Zope3/branches/jim-adapter/src/zope/security/meta.zcml 2006-04-12 23:28:07 UTC (rev 66922)
+++ Zope3/branches/jim-adapter/src/zope/security/meta.zcml 2006-04-12 23:37:35 UTC (rev 66923)
@@ -0,0 +1,24 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:meta="http://namespaces.zope.org/meta">
+
+ <meta:directive
+ namespace="http://namespaces.zope.org/zope"
+ name="permission"
+ schema=".zcml.IPermissionDirective"
+ handler=".zcml.permission" />
+
+ <meta:directive
+ name="securityPolicy"
+ namespace="http://namespaces.zope.org/zope"
+ schema=".zcml.ISecurityPolicyDirective"
+ handler=".zcml.securityPolicy"
+ />
+
+ <meta:directive
+ name="redefinePermission"
+ namespace="http://namespaces.zope.org/meta"
+ schema=".zcml.IRedefinePermission"
+ handler=".zcml.redefinePermission" />
+
+</configure>
Property changes on: Zope3/branches/jim-adapter/src/zope/security/meta.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: Zope3/branches/jim-adapter/src/zope/security/zcml.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/security/zcml.py 2006-04-12 23:28:07 UTC (rev 66922)
+++ Zope3/branches/jim-adapter/src/zope/security/zcml.py 2006-04-12 23:37:35 UTC (rev 66923)
@@ -16,12 +16,15 @@
$Id$
"""
__docformat__ = 'restructuredtext'
-from zope import schema
-from zope.interface import implements
+
+import zope.schema
+from zope.interface import Interface, implements
from zope.schema.interfaces import IFromUnicode
from zope.security.permission import checkPermission
+from zope.security.management import setSecurityPolicy
+from zope.configuration.fields import MessageID, GlobalObject
-class Permission(schema.Id):
+class Permission(zope.schema.Id):
r"""This field describes a permission.
Let's look at an example:
@@ -80,3 +83,64 @@
order=9999999,
)
+
+class ISecurityPolicyDirective(Interface):
+ """Defines the security policy that will be used for Zope."""
+
+ component = GlobalObject(
+ title=u"Component",
+ description=u"Pointer to the object that will handle the security.",
+ required=True)
+
+def securityPolicy(_context, component):
+ _context.action(
+ discriminator = 'defaultPolicy',
+ callable = setSecurityPolicy,
+ args = (component,) )
+
+class IPermissionDirective(Interface):
+ """Define a new security object."""
+
+ id = zope.schema.Id(
+ title=u"Id",
+ description=u"Id as which this object will be known and used.",
+ required=True)
+
+ title = MessageID(
+ title=u"Title",
+ description=u"Provides a title for the object.",
+ required=True)
+
+ description = MessageID(
+ title=u"Description",
+ description=u"Provides a description for the object.",
+ required=False)
+
+def permission(_context, id, title, description=''):
+ from zope.security.interfaces import IPermission
+ from zope.security.permission import Permission
+ from zope.component.zcml import utility
+ permission = Permission(id, title, description)
+ utility(_context, IPermission, permission, name=id)
+
+class IRedefinePermission(Interface):
+ """Define a permission to replace another permission."""
+
+ from_ = Permission(
+ title=u"Original permission",
+ description=u"Original permission id to redefine.",
+ required=True)
+
+ to = Permission(
+ title=u"Substituted permission",
+ description=u"Substituted permission id.",
+ required=True)
+
+def redefinePermission(_context, from_, to):
+ _context = _context.context
+
+ # check if context has any permission mappings yet
+ if not hasattr(_context, 'permission_mapping'):
+ _context.permission_mapping={}
+
+ _context.permission_mapping[from_] = to
More information about the Zope3-Checkins
mailing list