[z3-checkins] r5200 - in z3/Five/trunk: . security
faassen at codespeak.net
faassen at codespeak.net
Mon Jun 21 17:59:09 MEST 2004
Author: faassen
Date: Mon Jun 21 17:59:08 2004
New Revision: 5200
Removed:
z3/Five/trunk/metadirectives.py
z3/Five/trunk/security/fields.py
z3/Five/trunk/security/interfaces.py
Modified:
z3/Five/trunk/fivedirectives.py
z3/Five/trunk/security/permission.py
Log:
Remove a lot of schemas which are now defined in zope.app and we reuse them.
Also remove unneeded security definitions, as we can use the ones in
zope.app as well.
Modified: z3/Five/trunk/fivedirectives.py
==============================================================================
--- z3/Five/trunk/fivedirectives.py (original)
+++ z3/Five/trunk/fivedirectives.py Mon Jun 21 17:59:08 2004
@@ -1,112 +1,5 @@
from zope.interface import Interface
-from zope.configuration.fields import GlobalObject, Tokens,\
- PythonIdentifier, MessageID
-from zope.schema import TextLine, Id
-from Products.Five.security.fields import Permission
-
-class IBasicViewInformation(Interface):
- """
- This is the basic information for all views.
- """
-
- for_ = Tokens(
- title=u"Specifications of the objects to be viewed",
- description=u"""This should be a list of interfaces or classes
- """,
- required=True,
- value_type=GlobalObject(missing_value=object())
- )
-
- class_ = GlobalObject(
- title=u"Class",
- description=u"A class that provides attributes used by the view.",
- required=False
- )
-
- layer = TextLine(
- title=u"The layer the view is in.",
- description=u"""
- A skin is composed of layers. It is common to put skin
- specific views in a layer named after the skin. If the 'layer'
- attribute is not supplied, it defaults to 'default'.""",
- required=False
- )
-
-class IPagesDirective(IBasicViewInformation):
- """
- Define multiple pages without repeating all of the parameters.
-
- The pages directive allows multiple page views to be defined
- without repeating the 'for', 'permission', 'class', 'layer',
- 'allowed_attributes', and 'allowed_interface' attributes.
- """
-
- for_ = GlobalObject(
- title=u"The interface this view is for.",
- required=False
- )
-
-class IPagesPageSubdirective(Interface):
- """
- Subdirective to IPagesDirective
- """
-
- name = TextLine(
- title=u"The name of the page (view)",
- description=u"""
- The name shows up in URLs/paths. For example 'foo' or
- 'foo.html'. This attribute is required unless you use the
- subdirective 'page' to create sub views. If you do not have
- sub pages, it is common to use an extension for the view name
- such as '.html'. If you do have sub pages and you want to
- provide a view name, you shouldn't use extensions.""",
- required=True
- )
-
- template = TextLine(
- title=u"The name of a page template.",
- description=u"""
- Refers to a file containing a page template (must end in
- extension '.pt').""",
- required=False
- )
-
- attribute = PythonIdentifier(
- title=u"The name of an attribute to publish.",
- description=u"""
- This is used to publish an attribute provided by a class,
- instead of a template.
-
- This is the attribute, usually a method, to be published as
- the page (view). The default is "__call__".""",
- required=False
- )
-
- title = MessageID(
- title=u"The browser menu label for the page (view)",
- description=u"""
- This attribute must be supplied if a menu attribute is
- supplied.""",
- required=False
- )
-
- permission = Permission(
- title=u"Permission",
- description=u"""
- Specifies the permission by id that will be required to
- access or mutate the attributes and methods specified.""",
- required=False
- )
-
-
-class IPageDirective(IPagesDirective, IPagesPageSubdirective):
- """
- The page directive is used to create views that provide a single
- url or page.
-
- The page directive creates a new view class from a given template
- and/or class and registers it.
- """
+from zope.configuration.fields import GlobalObject, Tokens
class IImplementsDirective(Interface):
"""State that a class implements something.
@@ -130,41 +23,3 @@
required=True
)
-class ILayerDirective(Interface):
- """
- Register a layer
- """
-
- name = TextLine(
- title=u"Layer name",
- description=u"Layer name",
- required=True
- )
-
-class ISkinDirective(Interface):
- """
- Register a skin
- """
-
- name = TextLine(
- title=u"Skin name",
- description=u"Skin name",
- required=True
- )
-
- layers = Tokens(
- title=u"The layers it consists of.",
- required=True,
- value_type=TextLine()
- )
-
-class IDefaultSkinDirective(Interface):
- """
- Register a skin
- """
-
- name = TextLine(
- title=u"Default skin name",
- description=u"Default skin name",
- required=True
- )
Deleted: /z3/Five/trunk/metadirectives.py
==============================================================================
--- /z3/Five/trunk/metadirectives.py Mon Jun 21 17:59:08 2004
+++ (empty file)
@@ -1,141 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""
-$Id: metadirectives.py,v 1.2 2004/05/18 13:58:57 faassen Exp $
-"""
-from zope.interface import Interface
-from zope.configuration.fields import GlobalObject, Tokens, \
- PythonIdentifier, MessageID
-from zope.schema import TextLine, Id
-
-class IBasicComponentInformation(Interface):
-
- component = GlobalObject(
- title=u"Component to be used",
- required=False
- )
-
- factory = GlobalObject(
- title=u"Factory",
- required=False
- )
-
-class IServiceTypeDirective(Interface):
-
- id = TextLine(
- title=u"ID of the service type",
- required=True
- )
-
- interface = GlobalObject(
- title=u"Interface of the service type",
- required=True
- )
-
-class IServiceDirective(IBasicComponentInformation):
- """
- Register a service
- """
-
- serviceType = TextLine(
- title=u"ID of service type",
- required=True
- )
-
-class IInterfaceDirective(Interface):
- """
- Define an interface
- """
-
- interface = GlobalObject(
- title=u"Interface",
- required=True
- )
-
- type = GlobalObject(
- title=u"Interface type",
- required=False
- )
-
-class IAdapterDirective(Interface):
- """
- Register an adapter
- """
-
- factory = Tokens(
- title=u"Adapter factory/factories",
- description=u"""A list of factories (usually just one) that create the
- adapter instance.""",
- required=True,
- value_type=GlobalObject()
- )
-
- provides = GlobalObject(
- title=u"Interface the component provides",
- description=u"""This attribute specifes the interface the adapter
- instance must provide.""",
- required=True
- )
-
- for_ = Tokens(
- title=u"Specifications to be adapted",
- description=u"""This should be a list of interfaces or classes
- """,
- required=True,
- value_type=GlobalObject(missing_value=object())
- )
-
- name = TextLine(
- title=u"Name",
- description=u"""Adapters can have names. This attribute allows you to
- specify the name for this adapter.""",
- required=False
- )
-
-class IUtilityDirective(IBasicComponentInformation):
- """
- Register a utility
- """
-
- provides = GlobalObject(
- title=u"Interface the component provides",
- required=True
- )
-
- name = TextLine(
- title=u"Name",
- required=False
- )
-
-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."""
Deleted: /z3/Five/trunk/security/fields.py
==============================================================================
--- /z3/Five/trunk/security/fields.py Mon Jun 21 17:59:08 2004
+++ (empty file)
@@ -1,81 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (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.
-#
-##############################################################################
-"""Security related configuration fields.
-
-$Id: fields.py 25253 2004-06-04 15:20:26Z jim $
-"""
-from zope import schema
-from zope.interface import implements
-from zope.schema.interfaces import IFromUnicode
-
-from Products.Five.security.permission import checkPermission
-
-class Permission(schema.Id):
- r"""This field describes a permission.
-
- Let's look at an example:
-
- >>> class FauxContext:
- ... permission_mapping = {'zope.ManageCode':'zope.private'}
- ... _actions = []
- ... def action(self, **kws):
- ... self._actions.append(kws)
- >>> context = FauxContext()
- >>> field = Permission().bind(context)
-
- Let's test the fromUnicode method:
-
- >>> field.fromUnicode(u'zope.foo')
- 'zope.foo'
- >>> field.fromUnicode(u'zope.ManageCode')
- 'zope.private'
-
- Now let's see whether validation works alright
-
- >>> field._validate('zope.ManageCode')
- >>> context._actions[0]['args']
- (None, 'zope.foo')
- >>> field._validate('3 foo')
- Traceback (most recent call last):
- ...
- InvalidId: 3 foo
-
- zope.Public is always valid
- >>> field._validate('zope.Public')
- """
- implements(IFromUnicode)
-
- def fromUnicode(self, u):
- u = super(Permission, self).fromUnicode(u)
-
- map = getattr(self.context, 'permission_mapping', {})
- return map.get(u, u)
-
- def _validate(self, value):
- super(Permission, self)._validate(value)
-
- if value != 'zope.Public':
- self.context.action(
- discriminator = None,
- callable = checkPermission,
- args = (None, value),
-
- # Delay execution till end. This is an
- # optimization. We don't want to intersperse utility
- # lookup, done when checking permissions, with utility
- # definitions. Utility lookup is expensive after
- # utility definition, as extensive caches have to be
- # rebuilt.
- order=9999999,
- )
Deleted: /z3/Five/trunk/security/interfaces.py
==============================================================================
--- /z3/Five/trunk/security/interfaces.py Mon Jun 21 17:59:08 2004
+++ (empty file)
@@ -1,21 +0,0 @@
-from zope.interface import Interface
-from zope.schema import TextLine, Text
-
-class IPermission(Interface):
- """A permission object."""
-
- id = TextLine(
- title=u"Id",
- description=u"Id as which this permission will be known and used.",
- readonly=True,
- required=True)
-
- title = TextLine(
- title=u"Title",
- description=u"Provides a title for the permission.",
- required=True)
-
- description = Text(
- title=u"Description",
- description=u"Provides a description for the permission.",
- required=False)
Modified: z3/Five/trunk/security/permission.py
==============================================================================
--- z3/Five/trunk/security/permission.py (original)
+++ z3/Five/trunk/security/permission.py Mon Jun 21 17:59:08 2004
@@ -1,6 +1,6 @@
from zope.interface import implements
from zope.component import queryUtility
-from Products.Five.security.interfaces import IPermission
+from zope.app.security.interfaces import IPermission
CheckerPublic = 'zope.Public'
CheckerPrivate = 'zope.Private'
More information about the z3-checkins
mailing list