[Checkins] SVN: zope.app.component/trunk/ Removed the implementation of the <class> directive from
Brandon Rhodes
brandon at rhodesmill.org
Wed Jan 28 10:27:47 EST 2009
Log message for revision 95328:
Removed the implementation of the <class> directive from
zope.app.component since it has just been moved to zope.security.
Changed:
U zope.app.component/trunk/CHANGES.txt
U zope.app.component/trunk/setup.py
U zope.app.component/trunk/src/zope/app/component/contentdirective.py
U zope.app.component/trunk/src/zope/app/component/meta.zcml
U zope.app.component/trunk/src/zope/app/component/metadirectives.py
U zope.app.component/trunk/src/zope/app/component/tests/test_contentdirective.py
-=-
Modified: zope.app.component/trunk/CHANGES.txt
===================================================================
--- zope.app.component/trunk/CHANGES.txt 2009-01-28 15:15:25 UTC (rev 95327)
+++ zope.app.component/trunk/CHANGES.txt 2009-01-28 15:27:46 UTC (rev 95328)
@@ -2,9 +2,15 @@
CHANGES
=======
-3.5.1 (Unreleased)
+3.6.0 (Unreleased)
------------------
+- Moved the implementation of the <class> directive from this package to
+ `zope.security`. In particular, the module
+ `zope.app.component.contentdirective` has moved to
+ `zope.security.metaconfigure`, and a compatibility import has been
+ left in its place.
+
- Extracted `zope.site` from zope.app.component with backwards
compatibility imports in place. Local site related functionality
is now in `zope.site` and packages should import from there.
Modified: zope.app.component/trunk/setup.py
===================================================================
--- zope.app.component/trunk/setup.py 2009-01-28 15:15:25 UTC (rev 95327)
+++ zope.app.component/trunk/setup.py 2009-01-28 15:27:46 UTC (rev 95328)
@@ -22,7 +22,7 @@
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='zope.app.component',
- version = '3.5.1dev',
+ version = '3.6.0dev',
author='Zope Corporation and Contributors',
author_email='zope3-dev at zope.org',
description='Local Zope Component Support',
Modified: zope.app.component/trunk/src/zope/app/component/contentdirective.py
===================================================================
--- zope.app.component/trunk/src/zope/app/component/contentdirective.py 2009-01-28 15:15:25 UTC (rev 95327)
+++ zope.app.component/trunk/src/zope/app/component/contentdirective.py 2009-01-28 15:27:46 UTC (rev 95328)
@@ -11,162 +11,11 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-""" Register class directive.
+"""Backwards compatibility: moved this module to
+`zope.security.metaconfigure`.
$Id$
"""
__docformat__ = 'restructuredtext'
-from types import ModuleType
-
-from zope.component.interfaces import IFactory
-from zope.component.factory import Factory
-from zope.component.interface import provideInterface
-from zope.component.zcml import utility
-from zope.interface import classImplements
-from zope.schema.interfaces import IField
-from zope.configuration.exceptions import ConfigurationError
-
-from zope.app.security.protectclass import protectLikeUnto, protectName
-from zope.app.security.protectclass import protectSetAttribute
-
-PublicPermission = 'zope.Public'
-
-def dottedName(klass):
- if klass is None:
- return 'None'
- return klass.__module__ + '.' + klass.__name__
-
-class ProtectionDeclarationException(Exception):
- """Security-protection-specific exceptions."""
- pass
-
-class ClassDirective(object):
-
- def __init__(self, _context, class_):
- self.__id = dottedName(class_)
- self.__class = class_
- if isinstance(self.__class, ModuleType):
- raise ConfigurationError('Content class attribute must be a class')
- self.__context = _context
-
- def implements(self, _context, interface):
- for interface in interface:
- _context.action(
- discriminator = (
- 'ContentDirective', self.__class, object()),
- callable = classImplements,
- args = (self.__class, interface),
- )
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = (interface.__module__ + '.' + interface.getName(),
- interface)
- )
-
- def require(self, _context,
- permission=None, attributes=None, interface=None,
- like_class=None, set_attributes=None, set_schema=None):
- """Require a permission to access a specific aspect"""
- if like_class:
- self.__mimic(_context, like_class)
-
- if not (interface or attributes or set_attributes or set_schema):
- if like_class:
- return
- raise ConfigurationError("Nothing required")
-
- if not permission:
- raise ConfigurationError("No permission specified")
-
- if interface:
- for i in interface:
- if i:
- self.__protectByInterface(i, permission)
- if attributes:
- self.__protectNames(attributes, permission)
- if set_attributes:
- self.__protectSetAttributes(set_attributes, permission)
- if set_schema:
- for s in set_schema:
- self.__protectSetSchema(s, permission)
-
- def __mimic(self, _context, class_):
- """Base security requirements on those of the given class"""
- _context.action(
- discriminator=('mimic', self.__class, object()),
- callable=protectLikeUnto,
- args=(self.__class, class_),
- )
-
- def allow(self, _context, attributes=None, interface=None):
- """Like require, but with permission_id zope.Public"""
- return self.require(_context, PublicPermission, attributes, interface)
-
- def __protectByInterface(self, interface, permission_id):
- "Set a permission on names in an interface."
- for n, d in interface.namesAndDescriptions(1):
- self.__protectName(n, permission_id)
- self.__context.action(
- discriminator = None,
- callable = provideInterface,
- args = (interface.__module__ + '.' + interface.getName(),
- interface)
- )
-
- def __protectName(self, name, permission_id):
- "Set a permission on a particular name."
- self.__context.action(
- discriminator = ('protectName', self.__class, name),
- callable = protectName,
- args = (self.__class, name, permission_id)
- )
-
- def __protectNames(self, names, permission_id):
- "Set a permission on a bunch of names."
- for name in names:
- self.__protectName(name, permission_id)
-
- def __protectSetAttributes(self, names, permission_id):
- "Set a permission on a bunch of names."
- for name in names:
- self.__context.action(
- discriminator = ('protectSetAttribute', self.__class, name),
- callable = protectSetAttribute,
- args = (self.__class, name, permission_id)
- )
-
- def __protectSetSchema(self, schema, permission_id):
- "Set a permission on a bunch of names."
- _context = self.__context
- for name in schema:
- field = schema[name]
- if IField.providedBy(field) and not field.readonly:
- _context.action(
- discriminator = ('protectSetAttribute', self.__class, name),
- callable = protectSetAttribute,
- args = (self.__class, name, permission_id)
- )
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = (schema.__module__ + '.' + schema.getName(),
- schema)
- )
-
- def __call__(self):
- "Handle empty/simple declaration."
- return ()
-
- def factory(self, _context, id=None, title="", description=''):
- """Register a zmi factory for this class"""
-
- id = id or self.__id
- factoryObj = Factory(self.__class, title, description)
-
- # note factories are all in one pile, utilities and content,
- # so addable names must also act as if they were all in the
- # same namespace, despite the utilities/content division
- utility(_context, IFactory, factoryObj,
- permission=PublicPermission, name=id)
+from zope.security.metaconfigure import ClassDirective
Modified: zope.app.component/trunk/src/zope/app/component/meta.zcml
===================================================================
--- zope.app.component/trunk/src/zope/app/component/meta.zcml 2009-01-28 15:15:25 UTC (rev 95327)
+++ zope.app.component/trunk/src/zope/app/component/meta.zcml 2009-01-28 15:27:46 UTC (rev 95328)
@@ -25,34 +25,6 @@
handler="zope.app.component.metaconfigure.resource"
/>
- <meta:complexDirective
- name="class"
- schema=".metadirectives.IClassDirective"
- handler=".contentdirective.ClassDirective"
- >
-
- <meta:subdirective
- name="implements"
- schema=".metadirectives.IImplementsSubdirective"
- />
-
- <meta:subdirective
- name="require"
- schema=".metadirectives.IRequireSubdirective"
- />
-
- <meta:subdirective
- name="allow"
- schema=".metadirectives.IAllowSubdirective"
- />
-
- <meta:subdirective
- name="factory"
- schema=".metadirectives.IFactorySubdirective"
- />
-
- </meta:complexDirective>
-
</meta:directives>
</configure>
Modified: zope.app.component/trunk/src/zope/app/component/metadirectives.py
===================================================================
--- zope.app.component/trunk/src/zope/app/component/metadirectives.py 2009-01-28 15:15:25 UTC (rev 95327)
+++ zope.app.component/trunk/src/zope/app/component/metadirectives.py 2009-01-28 15:27:46 UTC (rev 95328)
@@ -176,122 +176,3 @@
required=False,
value_type=zope.configuration.fields.PythonIdentifier(),
)
-
-
-class IClassDirective(zope.interface.Interface):
- """Make statements about a class"""
-
- class_ = zope.configuration.fields.GlobalObject(
- title=_("Class"),
- required=True
- )
-
-class IImplementsSubdirective(zope.interface.Interface):
- """Declare that the class given by the content directive's class
- attribute implements a given interface
- """
-
- interface = zope.configuration.fields.Tokens(
- title=_("One or more interfaces"),
- required=True,
- value_type=zope.configuration.fields.GlobalInterface()
- )
-
-class IRequireSubdirective(zope.interface.Interface):
- """Indicate that the a specified list of names or the names in a
- given Interface require a given permission for access.
- """
-
- permission = zope.security.zcml.Permission(
- title=_("Permission"),
- description=_("""
- Specifies the permission by id that will be required to
- access or mutate the attributes and methods specified."""),
- required=False,
- )
-
- attributes = zope.configuration.fields.Tokens(
- title=_("Attributes and methods"),
- description=_("This is a list of attributes and methods"
- " that can be accessed."),
- required=False,
- value_type=zope.configuration.fields.PythonIdentifier(),
- )
-
- set_attributes = zope.configuration.fields.Tokens(
- title=_("Attributes that can be set"),
- description=_("This is a list of attributes that can be"
- " modified/mutated."),
- required=False,
- value_type=zope.configuration.fields.PythonIdentifier(),
- )
-
- interface = zope.configuration.fields.Tokens(
- title=_("Interfaces"),
- description=_("The listed interfaces' methods and attributes"
- " can be accessed."),
- required=False,
- value_type=zope.configuration.fields.GlobalInterface(),
- )
-
- set_schema = zope.configuration.fields.Tokens(
- title=_("The attributes specified by the schema can be set"),
- description=_("The listed schemas' properties can be"
- " modified/mutated."),
- required=False,
- value_type=zope.configuration.fields.GlobalInterface(),
- )
-
- like_class = zope.configuration.fields.GlobalObject(
- title=_("Configure like this class"),
- description=_("""
- This argument says that this content class should be configured in the
- same way the specified class' security is. If this argument is
- specified, no other argument can be used."""),
- required=False,
- )
-
-class IAllowSubdirective(zope.interface.Interface):
- """
- Declare a part of the class to be publicly viewable (that is,
- requires the zope.Public permission). Only one of the following
- two attributes may be used.
- """
-
- attributes = zope.configuration.fields.Tokens(
- title=_("Attributes"),
- required=False,
- value_type=zope.configuration.fields.PythonIdentifier(),
- )
-
- interface = zope.configuration.fields.Tokens(
- title=_("Interface"),
- required=False,
- value_type=zope.configuration.fields.GlobalInterface(),
- )
-
-class IFactorySubdirective(zope.interface.Interface):
- """Specify the factory used to create this content object"""
-
- id = zope.schema.Id(
- title=_("ID"),
- description=_("""
- the identifier for this factory in the ZMI factory
- identification scheme. If not given, defaults to the literal
- string given as the content directive's 'class' attribute."""),
- required=False,
- )
-
- title = zope.configuration.fields.MessageID(
- title=_("Title"),
- description=_("Text suitable for use in the 'add content' menu"
- " of a management interface"),
- required=False,
- )
-
- description = zope.configuration.fields.MessageID(
- title=_("Description"),
- description=_("Longer narrative description of what this"
- " factory does"),
- required=False,
- )
Modified: zope.app.component/trunk/src/zope/app/component/tests/test_contentdirective.py
===================================================================
--- zope.app.component/trunk/src/zope/app/component/tests/test_contentdirective.py 2009-01-28 15:15:25 UTC (rev 95327)
+++ zope.app.component/trunk/src/zope/app/component/tests/test_contentdirective.py 2009-01-28 15:27:46 UTC (rev 95328)
@@ -24,7 +24,7 @@
from zope.configuration.xmlconfig import xmlconfig, XMLConfig
import zope.component
-import zope.app.security
+import zope.security
import zope.app.component
from zope.app.testing.placelesssetup import PlacelessSetup
@@ -53,7 +53,7 @@
def setUp(self):
super(TestClassDirective, self).setUp()
XMLConfig('meta.zcml', zope.app.component)()
- XMLConfig('meta.zcml', zope.app.security)()
+ XMLConfig('meta.zcml', zope.security)()
try:
del ExampleClass.__implements__
@@ -139,7 +139,7 @@
def setUp(self):
super(TestFactorySubdirective, self).setUp()
XMLConfig('meta.zcml', zope.app.component)()
- XMLConfig('meta.zcml', zope.app.security)()
+ XMLConfig('meta.zcml', zope.security)()
def testFactory(self):
f = configfile("""
More information about the Checkins
mailing list