[Checkins] SVN: zope.generic/trunk/src/zope/generic/ refactored configurationAdapter:

Dominik Huber dominik.huber at perse.ch
Wed Apr 26 06:07:07 EDT 2006


Log message for revision 67614:
  refactored configurationAdapter:
  - generalize the model and move the code to .adapter
  
  type:
  - replace the configurationAdapter subdirective by the adapter subdirective
  
  several other fixes

Changed:
  A   zope.generic/trunk/src/zope/generic/adapter/
  A   zope.generic/trunk/src/zope/generic/adapter/DEPENDENCIES.cfg
  A   zope.generic/trunk/src/zope/generic/adapter/PUBLICATION.cfg
  A   zope.generic/trunk/src/zope/generic/adapter/README.txt
  A   zope.generic/trunk/src/zope/generic/adapter/SETUP.cfg
  A   zope.generic/trunk/src/zope/generic/adapter/__init__.py
  A   zope.generic/trunk/src/zope/generic/adapter/adapter.py
  A   zope.generic/trunk/src/zope/generic/adapter/api.py
  A   zope.generic/trunk/src/zope/generic/adapter/configure.zcml
  A   zope.generic/trunk/src/zope/generic/adapter/interfaces.py
  A   zope.generic/trunk/src/zope/generic/adapter/meta.zcml
  A   zope.generic/trunk/src/zope/generic/adapter/metaconfigure.py
  A   zope.generic/trunk/src/zope/generic/adapter/metadirectives.py
  A   zope.generic/trunk/src/zope/generic/adapter/property.py
  A   zope.generic/trunk/src/zope/generic/adapter/testing.py
  A   zope.generic/trunk/src/zope/generic/adapter/tests.py
  A   zope.generic/trunk/src/zope/generic/adapter/zope.generic.adapter-configure.zcml
  A   zope.generic/trunk/src/zope/generic/adapter/zope.generic.adpater-meta.zcml
  U   zope.generic/trunk/src/zope/generic/configuration/DEPENDENCIES.cfg
  U   zope.generic/trunk/src/zope/generic/configuration/README.txt
  U   zope.generic/trunk/src/zope/generic/configuration/adapter.py
  U   zope.generic/trunk/src/zope/generic/configuration/api.py
  U   zope.generic/trunk/src/zope/generic/configuration/base.py
  U   zope.generic/trunk/src/zope/generic/configuration/helper.py
  U   zope.generic/trunk/src/zope/generic/configuration/interfaces.py
  D   zope.generic/trunk/src/zope/generic/configuration/meta.zcml
  D   zope.generic/trunk/src/zope/generic/configuration/metaconfigure.py
  D   zope.generic/trunk/src/zope/generic/configuration/metadirectives.py
  U   zope.generic/trunk/src/zope/generic/configuration/testing.py
  D   zope.generic/trunk/src/zope/generic/configuration/zope.generic.configuration-meta.zcml
  A   zope.generic/trunk/src/zope/generic/factory/DEPENDENCIES.cfg
  U   zope.generic/trunk/src/zope/generic/factory/factory.py
  U   zope.generic/trunk/src/zope/generic/informationprovider/DEPENDENCIES.cfg
  U   zope.generic/trunk/src/zope/generic/informationprovider/base.py
  U   zope.generic/trunk/src/zope/generic/informationprovider/interfaces.py
  U   zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py
  U   zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py
  U   zope.generic/trunk/src/zope/generic/informationprovider/testing.py
  U   zope.generic/trunk/src/zope/generic/keyface/base.py
  U   zope.generic/trunk/src/zope/generic/operation/README.txt
  U   zope.generic/trunk/src/zope/generic/operation/base.py
  U   zope.generic/trunk/src/zope/generic/type/DEPENDENCIES.cfg
  U   zope.generic/trunk/src/zope/generic/type/EXAMPLE.txt
  U   zope.generic/trunk/src/zope/generic/type/README.txt
  U   zope.generic/trunk/src/zope/generic/type/base.py
  U   zope.generic/trunk/src/zope/generic/type/meta.zcml
  U   zope.generic/trunk/src/zope/generic/type/metaconfigure.py
  U   zope.generic/trunk/src/zope/generic/type/metadirectives.py
  U   zope.generic/trunk/src/zope/generic/type/tests.py

-=-
Added: zope.generic/trunk/src/zope/generic/adapter/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/DEPENDENCIES.cfg	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/DEPENDENCIES.cfg	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,13 @@
+zope.app.component
+zope.app.location
+zope.app.security
+zope.app.testing
+zope.component
+zope.configuration
+zope.generic.configuration
+zope.generic.directlyprovides
+zope.generic.keyface
+zope.generic.testing
+zope.interface
+zope.schema
+zope.testing
\ No newline at end of file


Property changes on: zope.generic/trunk/src/zope/generic/adapter/DEPENDENCIES.cfg
___________________________________________________________________
Name: svn:keywords
   + Id

Added: zope.generic/trunk/src/zope/generic/adapter/PUBLICATION.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/PUBLICATION.cfg	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/PUBLICATION.cfg	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: zope.generic.adapter
+Summary: Configuratons stores schema based configuration data using the schema as key.
+Author: Dominik Huber, Perse Engineering GmbH, Switzerland
+Author-email: dominik.huber at perse.ch
+License: ZPL 2.1
+Description:
+        This package offers a mechanism to declare a key interface (IKeyface).
+		The key interface can be used to lookup corresponding information providers
+		explicitly. 


Property changes on: zope.generic/trunk/src/zope/generic/adapter/PUBLICATION.cfg
___________________________________________________________________
Name: svn:keywords
   + Id

Added: zope.generic/trunk/src/zope/generic/adapter/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/README.txt	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/README.txt	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,105 @@
+===============
+Generic Adapter
+===============
+
+The directive generic:adapter allows to register trusted, locatable
+adapters. This is a convenience directive that merges the regular class- and
+adapter-directive.
+
+The directive does invoke the regular adapter directive, but provides a few
+convenience options:
+
+-   If the class does not implement ILocation, the locatalbe flag is set to
+    True.
+
+-   If the read- or writePermission is set the class directive is invoked the
+    following way:
+
+    -   If no attributes or set_attributes are declared we use the
+        provided interface for securtiy declarations. The interface or
+        set_schema attribute of the required subdirective is taken.
+
+    -   If attributes or set_attributes are those names are used for the 
+        security declaration. The attributes or set_attributes attribute of 
+        the required subdirective is taken.
+
+-   You don't have to define the class attribute if the provides interface 
+    provides zope.generic.configuration.IConfiguraitonType. In those cases the
+    adapter class is build by a generic configuration adapter class factory.
+
+-   You don't have to define the class attribute if the key attribute is 
+    set. In those cases the adapter class is build by a generic annotation
+    adapter class factory assuming the annotation is providing the provides
+    interface. (TODO: NOT IMPLEMENTED YET)
+
+
+Configurations convenience adapter
+----------------------------------
+
+First we declare a configuration schema that should adapted:
+
+    >>> from zope.schema import TextLine
+
+    >>> class IFooConfiguration(interface.Interface):
+    ...    foo = TextLine(title=u'Foo', required=False, default=u'Default config.')
+
+We register the configuration schema using generic:keyface directive:
+
+    >>> registerDirective('''
+    ... <generic:keyface
+    ...     keyface="example.IFooConfiguration"
+    ...     type="zope.generic.configuration.IConfigurationType"
+    ...     />
+    ... ''') 
+
+    >>> from zope.generic.configuration import IConfigurationType
+    >>> IConfigurationType.providedBy(IFooConfiguration)
+    True
+
+We implement a class which is providing the configuration mechanism:
+
+    >>> class IFoo(interface.Interface):
+    ...    pass
+
+    >>> registerDirective('''
+    ... <generic:keyface
+    ...     keyface="example.IFoo"
+    ...     />
+    ... ''')
+    
+    >>> from zope.generic.configuration.api import IAttributeConfigurable
+
+    >>> class Foo(object):
+    ...     interface.implements(IFoo, IAttributeConfigurable)
+
+    >>> foo = Foo()
+
+    >>> from zope.generic.configuration.api import queryConfiguration
+    >>> queryConfiguration(foo, IFooConfiguration) is None
+    True
+
+Now we can provide an configuration adapter by a corresponding registration:
+
+    >>> registerDirective('''
+    ... <generic:adapter
+    ...     for="example.IFoo"
+    ...     provides="example.IFooConfiguration"
+    ...     readPermission="zope.Public"
+    ...     writePermission="zope.Public"
+    ...     />
+    ... ''')
+
+We can adapt our foo to IFooConfiguration:
+
+    >>> adapted = IFooConfiguration(foo)
+    >>> IFooConfiguration.providedBy(adapted)
+    True
+    >>> adapted.foo
+    u'Default config.'
+
+    >>> adapted.foo = u'Foo config.'
+    >>> adapted.foo
+    u'Foo config.'
+
+    >>> queryConfiguration(foo, IFooConfiguration).foo
+    u'Foo config.'


Property changes on: zope.generic/trunk/src/zope/generic/adapter/README.txt
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/SETUP.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/SETUP.cfg	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/SETUP.cfg	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,3 @@
+<data-files zopeskel/etc/package-includes>
+  zope.generic.adapter-*.zcml
+</data-files>
\ No newline at end of file


Property changes on: zope.generic/trunk/src/zope/generic/adapter/SETUP.cfg
___________________________________________________________________
Name: svn:keywords
   + Id

Added: zope.generic/trunk/src/zope/generic/adapter/__init__.py
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/__init__.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/__init__.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,19 @@
+##############################################################################
+#
+# Copyright (c) 2005, 2006 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.
+#
+##############################################################################
+
+"""
+$Id$
+"""
+
+from zope.generic.adapter.interfaces import *
\ No newline at end of file


Property changes on: zope.generic/trunk/src/zope/generic/adapter/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/adapter.py
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/adapter.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/adapter.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,139 @@
+##############################################################################
+#
+# Copyright (c) 2005, 2006 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.
+#
+##############################################################################
+
+"""
+$Id$
+"""
+
+__docformat__ = 'restructuredtext'
+
+from zope.app.location import Location
+from zope.interface import classImplements
+from zope.interface import implements
+
+from zope.generic.configuration import IConfigurationType
+from zope.generic.configuration import IConfigurations
+
+from zope.generic.adapter.property import ConfigurationAdapterProperty
+
+
+
+class ConfigurationAdapterBase(Location):
+    """Base mixin for simple configuration adapter."""
+
+    __keyface__ = None
+
+    def __init__(self, context):
+        self.__context__ = context
+        self.__configurations__ = IConfigurations(context)
+
+
+
+def ConfigurationAdapterClass(keyface, informationProviders=None, bases=()):
+    """Generic configuration adapter class factory.
+
+    The generic configuration adapter is a generic adapter class for 
+    instances providing configurations. First we declare a configuration
+    schema:
+
+        >>> from zope.schema import TextLine
+
+        >>> class IFooConfiguration(interface.Interface):
+        ...    foo = TextLine(title=u'Foo', required=False, default=u'Default config.')
+
+    We register the configuration schema using generic:keyface directive:
+
+        >>> registerDirective('''
+        ... <generic:keyface
+        ...     keyface="example.IFooConfiguration"
+        ...     type="zope.generic.configuration.IConfigurationType"
+        ...     />
+        ... ''') 
+
+        >>> from zope.generic.configuration import IConfigurationType
+        >>> IConfigurationType.providedBy(IFooConfiguration)
+        True
+
+    We implement a class which is providing the configuration mechanism:
+    
+        >>> class IFoo(interface.Interface):
+        ...    pass
+
+        >>> registerDirective('''
+        ... <generic:keyface
+        ...     keyface="example.IFoo"
+        ...     />
+        ... ''')
+
+        >>> from zope.generic.configuration import IAttributeConfigurable
+
+        >>> class Foo(object):
+        ...     interface.implements(IFoo, IAttributeConfigurable)
+
+        >>> foo = Foo()
+
+        >>> from zope.generic.configuration.api import queryConfiguration
+
+        >>> queryConfiguration(foo, IFooConfiguration) is None
+        True
+
+    The simple configuration adapter function will construct an adapter class
+    implementing the IFooConfiguration interface:
+
+        >>> from zope.generic.adapter.adapter import ConfigurationAdapterClass
+        
+        >>> FooConfigurationAdapter = ConfigurationAdapterClass(IFooConfiguration)
+        >>> IFooConfiguration.implementedBy(FooConfigurationAdapter)
+        True
+
+    We can adapt our foo to IFooConfiguration:
+
+        >>> adapted = FooConfigurationAdapter(foo)
+        >>> IFooConfiguration.providedBy(adapted)
+        True
+        >>> adapted.foo
+        u'Default config.'
+
+        >>> adapted.foo = u'Foo config.'
+        >>> adapted.foo
+        u'Foo config.'
+
+        >>> queryConfiguration(foo, IFooConfiguration).foo
+        u'Foo config.'
+
+        >>> adapted.foo = u'Another foo value.'
+        >>> adapted.foo
+        u'Another foo value.'
+
+    """
+
+    # preconditions
+    if not IConfigurationType.providedBy(keyface):
+        raise ValueError('Interface must provide %s.' % IConfigurationType.__name__)
+
+    # essentails
+    if not bases:
+        bases = (ConfigurationAdapterBase, )
+
+    class_ = type('ConfigurationAdapterClass from %s' % keyface, bases,
+                  {'__keyface__': keyface})
+
+    classImplements(class_, keyface)
+
+    # add field properties for each object field
+    for name in keyface:
+        field = keyface[name]
+        setattr(class_, name, ConfigurationAdapterProperty(keyface[name], providers=informationProviders))
+
+    return class_


Property changes on: zope.generic/trunk/src/zope/generic/adapter/adapter.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/api.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/api.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,23 @@
+##############################################################################
+#
+# Copyright (c) 2005, 2006 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.
+#
+##############################################################################
+
+"""
+$Id$
+"""
+
+__docformat__ = 'restructuredtext'
+
+from zope.generic.adapter import *
+from zope.generic.adapter.adapter import ConfigurationAdapterClass
+from zope.generic.adapter.property import ConfigurationAdapterProperty


Property changes on: zope.generic/trunk/src/zope/generic/adapter/api.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/configure.zcml	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/configure.zcml	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,6 @@
+<configure
+  xmlns="http://namespaces.zope.org/zope"
+  xmlns:generic="http://namespaces.zope.org/generic"
+  i18n_domain="zope">
+
+</configure>


Property changes on: zope.generic/trunk/src/zope/generic/adapter/configure.zcml
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/interfaces.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/interfaces.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,19 @@
+##############################################################################
+#
+# Copyright (c) 2005, 2006 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.
+#
+##############################################################################
+
+"""
+$Id$
+"""
+
+__docformat__ = 'restructuredtext'


Property changes on: zope.generic/trunk/src/zope/generic/adapter/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/meta.zcml	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/meta.zcml	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,15 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:meta="http://namespaces.zope.org/meta">
+
+  <meta:directives namespace="http://namespaces.zope.org/generic">
+
+    <meta:directive
+        name="adapter"
+        schema=".metadirectives.IAdapterDirective"
+        handler=".metaconfigure.adapterDirective"
+        />
+
+  </meta:directives>
+
+</configure>


Property changes on: zope.generic/trunk/src/zope/generic/adapter/meta.zcml
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/metaconfigure.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/metaconfigure.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,83 @@
+##############################################################################
+#
+# Copyright (c) 2005, 2006 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.
+#
+##############################################################################
+
+"""
+$Id$
+"""
+
+__docformat__ = 'restructuredtext'
+
+from zope.app.component.contentdirective import ClassDirective
+from zope.app.component.metaconfigure import adapter
+from zope.app.location import ILocation
+from zope.configuration.exceptions import ConfigurationError
+
+from zope.generic.configuration import IConfigurationType
+
+from zope.generic.adapter.adapter import ConfigurationAdapterClass
+
+
+
+def adapterDirective(_context, provides, for_=None, class_=None, 
+                     writePermission=None, readPermission=None, attributes=None,
+                     set_attributes=None, key=None, informationProviders=None):
+    """Provide a generic locatable and trusted adatpers."""
+
+    # assert for list
+    if for_ is None:
+        for_ = []
+
+    if class_ and (key or informationProviders):
+        raise ConfigurationError('Use class or key/ informationProividers attriubte.')
+
+    # we will provide a generic adapter class
+    if class_ is None and IConfigurationType.providedBy(provides):
+        class_ = ConfigurationAdapterClass(provides, informationProviders)
+
+    if class_ is None and key:
+        raise NotImplementedError('Missing feature: You cannot use the key attribute yet.')
+        #class_ = AnnotationAdapterClass(provides)
+
+    if class_ is None:
+        raise ConfigurationError('No class is given or could be evaluated.')
+
+    # register class and set its permissions
+    class_directive = ClassDirective(_context, class_)
+    if writePermission:
+        # use the provided interface to declare the write permission
+        if set_attributes is None:
+            class_directive.require(_context, permission=writePermission, set_schema=[provides])
+
+        # use set attributes to declare the write permission
+        else:
+            class_directive.require(_context, permission=writePermission, set_attributes=set_attributes)
+
+    if readPermission:
+        # use the provided interface to declare the read permission
+        if attributes is None:
+            class_directive.require(_context, permission=readPermission, interface=[provides])
+
+        # use attributes to declare the read permission
+        else:
+            class_directive.require(_context, permission=writePermission, attributes=attributes)
+
+    # evalute if location is provided by the adapters
+    locate = False
+    if not ILocation.implementedBy(class_):
+        locate = True
+
+    # register adapter
+    adapter(_context, factory=[class_], provides=provides, 
+            for_=for_, permission=None, name='', trusted=True, 
+            locate=locate)


Property changes on: zope.generic/trunk/src/zope/generic/adapter/metaconfigure.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/metadirectives.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/metadirectives.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,107 @@
+##############################################################################
+#
+# Copyright (c) 2005, 2006 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.
+#
+##############################################################################
+
+"""
+$Id$
+"""
+
+__docformat__ = 'restructuredtext'
+
+from zope.app.i18n import ZopeMessageFactory as _
+from zope.app.security.fields import Permission
+from zope.configuration.fields import GlobalInterface
+from zope.configuration.fields import GlobalObject
+from zope.configuration.fields import PythonIdentifier
+from zope.configuration.fields import Tokens
+from zope.interface import Interface
+from zope.schema import DottedName
+
+
+class IForAdapterDirective(Interface):
+    """Declare the for attribute."""
+
+    for_ = Tokens(
+        title=_('Specifications to be adapted'),
+        description=_('This should be a list of interfaces or classes.'),
+        required=False,
+        value_type=GlobalObject(missing_value=object())
+        )
+
+
+
+class IOthersAdapterDirective(Interface):
+    """Declare all others attributes."""
+
+    provides = GlobalInterface(
+        title=_('Provided Interface'),
+        description=_('The interface that is provided by the adapter.'),
+        required=True
+        )
+
+    class_ = GlobalObject(
+        title=_('Adapter class'),
+        description=_('If not declared a generic implementation will be used.'),
+        required=False
+        )
+
+    writePermission = Permission(
+        title=_('Write Permission'),
+        description=_('Specifies the permission by id that will be required '
+            'to mutate the attributes and methods specified.'),
+        required=False,
+        )
+
+    readPermission = Permission(
+        title=_('Read Permission'),
+        description=_('Specifies the permission by id that will be required '
+            'to accessthe attributes and methods specified.'),
+        required=False,
+        )
+
+    attributes = Tokens(
+        title=_('Attributes and methods'),
+        description=_('This is a list of attributes and methods '
+            'that can be accessed.'),
+        required=False,
+        value_type=PythonIdentifier(),
+        )
+
+    set_attributes = Tokens(
+        title=_('Attributes that can be set'),
+        description=_('This is a list of attributes that can be '
+            'modified/mutated.'),
+        required=False,
+        value_type=PythonIdentifier(),
+        )
+
+    key = DottedName(
+        title=_('Interface'),
+        description=_('Interface referencing a configuraiton.'),
+        required=False
+        )
+
+    informationProviders = Tokens(
+        title=_('Information Providers'),
+        description=_('This information provides should be invoke '
+            'to lookup informations such as configurations and annotations.'),
+        required=False,
+        value_type=GlobalInterface(),
+        )
+
+
+class IAdapterDirective(IForAdapterDirective, IOthersAdapterDirective):
+    """Provide trusted locatable adapter including permissions."""
+
+ 
+


Property changes on: zope.generic/trunk/src/zope/generic/adapter/metadirectives.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/property.py
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/property.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/property.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,135 @@
+##############################################################################
+#
+# Copyright (c) 2005, 2006 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.
+#
+##############################################################################
+
+"""
+$Id$
+"""
+
+__docformat__ = 'restructuredtext'
+
+from zope.generic.configuration import IConfigurations
+from zope.generic.configuration.base import ConfigurationData
+from zope.generic.configuration.helper import configuratonToDict
+from zope.generic.informationprovider.api import getInformation
+from zope.generic.informationprovider.api import getInformationProvider
+
+
+
+_marker = object()
+
+class ConfigurationAdapterProperty(object):
+    """Compute configuration adapter attributes based on schema fields
+
+    Field properties provide default values, data validation and error messages
+    based on data found in field meta-data.
+
+    Note that ConfigurationAdapterProperty cannot be used with slots. 
+    They can only be used for attributes stored in instance configurations
+    dictionaries.
+    """
+
+    def __init__(self, field, name=None, providers=None):
+        if name is None:
+            name = field.__name__
+
+        self._field = field
+        self._name = name
+        self._providers = providers
+
+    def __get__(self, inst, klass):
+        if inst is None:
+            return self
+
+        # assume attribute configurables
+        try:
+            configurations = inst.__configurations__
+
+        # try to adapt
+        except:
+            configurations = IConfigurations(inst)
+
+        keyface = inst.__keyface__
+        context = inst.__context__
+
+        # evaluate configuration
+        configuration = inst.__keyface__(configurations, None)
+        # Try to evaluate configuration from information provider
+        if configuration is None and self._providers:
+            for registry in self._providers:
+                try:
+                    provider = getInformationProvider(context, registry)
+                    configuration = getInformation(provider, keyface)
+                    break
+                except:
+                    pass
+
+        value = getattr(configuration, self._name, _marker)
+        if value is _marker:
+            field = self._field.bind(inst)
+            value = getattr(field, 'default', _marker)
+            if value is _marker:
+                raise AttributeError(self._name)
+
+        return value
+
+    def __set__(self, inst, value):
+        field = self._field.bind(inst)
+        field.validate(value)
+        if field.readonly:
+            raise ValueError(self._name, 'field is readonly')
+
+        # assume attribute configurables
+        try:
+            configurations = inst.__configurations__
+
+        # try to adapt
+        except:
+            configurations = IConfigurations(inst)
+
+        keyface = inst.__keyface__
+        # update existing configuration
+        if keyface in configurations:
+            configurations.update(keyface, {self._name: value})
+            
+        # create a new configuration
+        else:
+            try:
+                configurations[keyface] = ConfigurationData(keyface, {self._name: value})
+
+            except TypeError, e:
+                # hack around the atomic update of the form framework
+                # try to invoke acquire settings
+                context = inst.__context__
+                configuration = None
+                if configuration is None and self._providers:
+                    for registry in self._providers:
+                        try:
+                            provider = getInformationProvider(context, registry)
+                            configuration = getInformation(provider, keyface)
+                            break
+                        except:
+                            pass
+
+                # no information available
+                if not configuration:
+                    raise
+
+                data = configuratonToDict(configuration)
+                data[self._name] = value
+                configurations[keyface] = ConfigurationData(keyface, data)
+
+        inst.__dict__[self._name] = value
+
+    def __getattr__(self, name):
+        return getattr(self._field, name)


Property changes on: zope.generic/trunk/src/zope/generic/adapter/property.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/testing.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/testing.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,106 @@
+##############################################################################
+#
+# Copyright (c) 2005, 2006 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.
+#
+##############################################################################
+
+"""
+$Id$
+"""
+
+__docformat__ = 'restructuredtext'
+
+import zope.app.testing.placelesssetup
+from zope.configuration.xmlconfig import XMLConfig
+from zope.interface import Interface
+from zope.schema import TextLine
+
+import zope.generic.adapter.testing
+import zope.generic.configuration.testing
+import zope.generic.directlyprovides.testing
+import zope.generic.keyface.testing
+import zope.generic.testing.testing
+
+################################################################################
+#
+# Public Test implementations
+#
+################################################################################
+
+class IMarker(Interface):
+    """Demo marker."""
+
+
+class IBarConfiguration(Interface):
+
+    bar = TextLine(title=u'Bar')
+
+
+class IInputConfiguration(Interface):
+
+    foo = TextLine(title=u'Foo')
+
+    bar = TextLine(title=u'Bar')
+
+
+class IFooConfiguration(Interface):
+
+    foo = TextLine(title=u'Foo')
+    
+    fo = TextLine(title=u'Fo', required=False, readonly=True, default=u'fo default')
+
+
+class TestKeyfaceAttriute(object):
+    __keyface__ = IFooConfiguration
+
+
+################################################################################
+#
+# Placeless setup
+#
+################################################################################
+
+# specific tests
+def setUp(doctest=None):
+    # register the directive of this package
+    import zope.generic.adapter
+    XMLConfig('meta.zcml', zope.generic.adapter)()
+
+def tearDown(doctest=None):
+    pass
+
+
+
+class PlacelessSetup(zope.app.testing.placelesssetup.PlacelessSetup):
+
+    def setUp(self, doctest=None):
+        super(PlacelessSetup, self).setUp(doctest)
+        # external setup
+        zope.generic.testing.testing.setUp(doctest)
+        zope.generic.directlyprovides.testing.setUp(doctest)
+        zope.generic.keyface.testing.setUp(doctest)
+        zope.generic.configuration.testing.setUp(doctest)
+        zope.generic.adapter.testing.setUp(doctest)
+        # internal setup
+        setUp(doctest)
+
+    def tearDown(self, doctest=None):
+        # internal teardown
+        tearDown(doctest)
+        # external teardown
+        zope.generic.adapter.testing.tearDown(doctest)
+        zope.generic.configuration.testing.tearDown(doctest)
+        zope.generic.keyface.testing.tearDown(doctest)
+        zope.generic.directlyprovides.testing.tearDown(doctest)
+        zope.generic.testing.testing.tearDown(doctest)
+        super(PlacelessSetup, self).tearDown()
+
+placelesssetup = PlacelessSetup()


Property changes on: zope.generic/trunk/src/zope/generic/adapter/testing.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/tests.py
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/tests.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/tests.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,58 @@
+##############################################################################
+#
+# Copyright (c) 2005, 2006 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.
+#
+##############################################################################
+
+"""
+$Id$
+"""
+
+import unittest
+
+from zope import component
+from zope import interface
+from zope.testing import doctest
+
+from zope.generic.testing.testing import registerDirective
+
+from zope.generic.adapter import api
+from zope.generic.adapter import testing
+
+
+###############################################################################
+#
+# Unit tests  
+#
+###############################################################################
+
+
+def test_suite():
+    return unittest.TestSuite((
+        doctest.DocTestSuite('zope.generic.adapter.adapter',
+                             setUp=testing.placelesssetup.setUp,
+                             tearDown=testing.placelesssetup.tearDown,
+                             globs={'component': component, 'interface': interface,
+                             'registerDirective': registerDirective,
+                             'testing': testing, 'api': api},
+                             optionflags=doctest.NORMALIZE_WHITESPACE+
+                                            doctest.ELLIPSIS),
+        doctest.DocFileSuite('README.txt',
+                             setUp=testing.placelesssetup.setUp,
+                             tearDown=testing.placelesssetup.tearDown,
+                             globs={'component': component, 'interface': interface,
+                             'registerDirective': registerDirective,
+                             'testing': testing, 'api': api},
+                             optionflags=doctest.NORMALIZE_WHITESPACE+
+                                            doctest.ELLIPSIS),
+        ))
+
+if __name__ == '__main__': unittest.main()


Property changes on: zope.generic/trunk/src/zope/generic/adapter/tests.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/zope.generic.adapter-configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/zope.generic.adapter-configure.zcml	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/zope.generic.adapter-configure.zcml	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+  <include package="zope.generic.adapter" />
+
+</configure>


Property changes on: zope.generic/trunk/src/zope/generic/adapter/zope.generic.adapter-configure.zcml
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/adapter/zope.generic.adpater-meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/zope.generic.adpater-meta.zcml	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/adapter/zope.generic.adpater-meta.zcml	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+  <include package="zope.generic.adapter" file="meta.zcml" />
+
+</configure>


Property changes on: zope.generic/trunk/src/zope/generic/adapter/zope.generic.adpater-meta.zcml
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: zope.generic/trunk/src/zope/generic/configuration/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/DEPENDENCIES.cfg	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/configuration/DEPENDENCIES.cfg	2006-04-26 10:07:05 UTC (rev 67614)
@@ -4,7 +4,6 @@
 zope.app.location
 zope.app.testing
 zope.component
-zope.configuration
 zope.event
 zope.generic.directlyprovides
 zope.generic.keyface

Modified: zope.generic/trunk/src/zope/generic/configuration/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/README.txt	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/configuration/README.txt	2006-04-26 10:07:05 UTC (rev 67614)
@@ -203,75 +203,3 @@
     >>> event = events.pop()
     >>> [(key.__name__, value) for key, value in event.items()]
     [('IFooConfiguration', {})]
-
-
-Configuration Adapter
----------------------
-
-The directive generic:configurationAdapter allows to register trusted, locatable
-adapters to a configuration schema.
-
-First we declare a configuration schema that should adapted:
-
-    >>> from zope.schema import TextLine
-
-    >>> class IFooConfiguration(interface.Interface):
-    ...    foo = TextLine(title=u'Foo', required=False, default=u'Default config.')
-
-We register the configuration schema using generic:keyface directive:
-
-    >>> registerDirective('''
-    ... <generic:keyface
-    ...     keyface="example.IFooConfiguration"
-    ...     type="zope.generic.configuration.IConfigurationType"
-    ...     />
-    ... ''') 
-
-    >>> from zope.generic.configuration import IConfigurationType
-    >>> IConfigurationType.providedBy(IFooConfiguration)
-    True
-
-We implement a class which is providing the configuration mechanism:
-
-    >>> class IFoo(interface.Interface):
-    ...    pass
-
-    >>> registerDirective('''
-    ... <generic:keyface
-    ...     keyface="example.IFoo"
-    ...     />
-    ... ''')
-
-    >>> class Foo(object):
-    ...     interface.implements(IFoo, api.IAttributeConfigurable)
-
-    >>> foo = Foo()
-
-    >>> api.queryConfiguration(foo, IFooConfiguration) is None
-    True
-
-Now we can provide an configuration adapter by a corresponding registration:
-
-    >>> registerDirective('''
-    ... <generic:configurationAdapter
-    ...     keyface="example.IFoo"
-    ...     provides="example.IFooConfiguration"
-    ...     readPermission="zope.Public"
-    ...     writePermission="zope.Public"
-    ...     />
-    ... ''')
-
-We can adapt our foo to IFooConfiguration:
-
-    >>> adapted = IFooConfiguration(foo)
-    >>> IFooConfiguration.providedBy(adapted)
-    True
-    >>> adapted.foo
-    u'Default config.'
-
-    >>> adapted.foo = u'Foo config.'
-    >>> adapted.foo
-    u'Foo config.'
-
-    >>> api.queryConfiguration(foo, IFooConfiguration).foo
-    u'Foo config.'

Modified: zope.generic/trunk/src/zope/generic/configuration/adapter.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/adapter.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/configuration/adapter.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -26,17 +26,14 @@
 from zope.app.location.interfaces import ILocation
 from zope.component import adapts
 from zope.event import notify
-from zope.interface import classImplements
 from zope.interface import implements
 
-from zope.generic.keyface import IAttributeKeyfaced
 from zope.generic.keyface.api import toDottedName
 from zope.generic.keyface.api import toKeyface
 
 from zope.generic.configuration import IAttributeConfigurable
 from zope.generic.configuration import IConfigurationType
 from zope.generic.configuration import IConfigurations
-from zope.generic.configuration.base import ConfigurationData
 from zope.generic.configuration.event import Configuration
 from zope.generic.configuration.event import ObjectConfiguredEvent
 from zope.generic.configuration.helper import configuratonToDict
@@ -144,175 +141,3 @@
         if ILocation.providedBy(parent) and parent.__parent__ is not None:
             notify(ObjectConfiguredEvent(parent, 
                 Configuration(keyface, {})))
-
-
-
-_marker = object()
-
-class ConfigurationAdapterProperty(object):
-    """Compute configuration adapter attributes based on schema fields
-
-    Field properties provide default values, data validation and error messages
-    based on data found in field meta-data.
-
-    Note that ConfigurationAdapterProperty cannot be used with slots. 
-    They can only be used for attributes stored in instance configurations
-    dictionaries.
-    """
-
-    def __init__(self, field, name=None):
-        if name is None:
-            name = field.__name__
-
-        self._field = field
-        self._name = name
-
-    def __get__(self, inst, klass):
-        if inst is None:
-            return self
-
-        configurations = inst.__configurations__
-        keyface = inst.__keyface__
-        context = inst.__context__
-
-        # evaluate configuration
-        configuration = inst.__keyface__(configurations, None)
-        value = getattr(configuration, self._name, _marker)
-        if value is _marker:
-            field = self._field.bind(inst)
-            value = getattr(field, 'default', _marker)
-            if value is _marker:
-                raise AttributeError(self._name)
-
-        return value
-
-    def __set__(self, inst, value):
-        field = self._field.bind(inst)
-        field.validate(value)
-        if field.readonly:
-            raise ValueError(self._name, 'field is readonly')
-
-        configurations = inst.__configurations__
-        keyface = inst.__keyface__
-        # update existing configuration
-        if keyface in configurations:
-            configurations.update(keyface, {self._name: value})
-            
-        # create a new configuration
-        else:
-            configurations[keyface] = ConfigurationData(keyface, {self._name: value})
-
-        inst.__dict__[self._name] = value
-
-    def __getattr__(self, name):
-        return getattr(self._field, name)
-
-
-
-class ConfigurationAdapterBase(Location):
-    """Base mixin for simple configuration adapter."""
-
-    __keyface__ = None
-
-    def __init__(self, context):
-        self.__context__ = context
-        self.__configurations__ = IConfigurations(context)
-
-
-
-def ConfigurationAdapterClass(keyface, bases=(), property=None):
-    """Generic configuration adapter class factory.
-
-    The generic configuration adapter is a generic adapter class for 
-    instances providing configurations. First we declare a configuration
-    schema:
-
-        >>> from zope.schema import TextLine
-
-        >>> class IFooConfiguration(interface.Interface):
-        ...    foo = TextLine(title=u'Foo', required=False, default=u'Default config.')
-
-    We register the configuration schema using generic:keyface directive:
-
-        >>> registerDirective('''
-        ... <generic:keyface
-        ...     keyface="example.IFooConfiguration"
-        ...     type="zope.generic.configuration.IConfigurationType"
-        ...     />
-        ... ''') 
-
-        >>> from zope.generic.configuration import IConfigurationType
-        >>> IConfigurationType.providedBy(IFooConfiguration)
-        True
-
-    We implement a class which is providing the configuration mechanism:
-    
-        >>> class IFoo(interface.Interface):
-        ...    pass
-
-        >>> registerDirective('''
-        ... <generic:keyface
-        ...     keyface="example.IFoo"
-        ...     />
-        ... ''')
-
-        >>> class Foo(object):
-        ...     interface.implements(IFoo, api.IAttributeConfigurable)
-
-        >>> foo = Foo()
-
-        >>> api.queryConfiguration(foo, IFooConfiguration) is None
-        True
-
-    The simple configuration adapter function will construct an adapter class
-    implementing the IFooConfiguration interface:
-
-        >>> from zope.generic.configuration.adapter import ConfigurationAdapterClass
-        
-        >>> FooConfigurationAdapter = ConfigurationAdapterClass(IFooConfiguration)
-        >>> IFooConfiguration.implementedBy(FooConfigurationAdapter)
-        True
-
-    We can adapt our foo to IFooConfiguration:
-
-        >>> adapted = FooConfigurationAdapter(foo)
-        >>> IFooConfiguration.providedBy(adapted)
-        True
-        >>> adapted.foo
-        u'Default config.'
-
-        >>> adapted.foo = u'Foo config.'
-        >>> adapted.foo
-        u'Foo config.'
-
-        >>> api.queryConfiguration(foo, IFooConfiguration).foo
-        u'Foo config.'
-
-        >>> adapted.foo = u'Another foo value.'
-        >>> adapted.foo
-        u'Another foo value.'
-
-    """
-
-    # preconditions
-    if not IConfigurationType.providedBy(keyface):
-        raise ValueError('Interface must provide %s.' % IConfigurationType.__name__)
-
-    # essentails
-    if not bases:
-        bases = (ConfigurationAdapterBase, )
-
-    class_ = type('ConfigurationAdapterClass from %s' % keyface, bases,
-                  {'__keyface__': keyface})
-
-    classImplements(class_, keyface)
-    
-    if property is None:
-        property = ConfigurationAdapterProperty
-
-    # add field properties for each object field
-    for name in keyface:
-        field = keyface[name]
-        setattr(class_, name, property(keyface[name]))
-
-    return class_

Modified: zope.generic/trunk/src/zope/generic/configuration/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/api.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/configuration/api.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -20,10 +20,8 @@
 
 from zope.generic.configuration import *
 from zope.generic.configuration.adapter import AttributeConfigurations
-from zope.generic.configuration.adapter import ConfigurationAdapterClass
-from zope.generic.configuration.adapter import ConfigurationAdapterProperty
 from zope.generic.configuration.base import ConfigurationData
-from zope.generic.configuration.helper import argumentsToConfiguration
+from zope.generic.configuration.helper import parameterToConfiguration
 from zope.generic.configuration.helper import configuratonToDict
 from zope.generic.configuration.helper import requiredInOrder
 

Modified: zope.generic/trunk/src/zope/generic/configuration/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/base.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/configuration/base.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -22,7 +22,6 @@
 from persistent import IPersistent
 from persistent.dict import PersistentDict
 
-from zope.app.i18n import ZopeMessageFactory as _
 from zope.interface import directlyProvides
 from zope.interface import implements
 from zope.interface.interfaces import IMethod

Modified: zope.generic/trunk/src/zope/generic/configuration/helper.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/helper.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/configuration/helper.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -105,7 +105,7 @@
 
 
 
-def argumentsToConfiguration(__keyface__, *pos, **kws):
+def parameterToConfiguration(__keyface__, *pos, **kws):
     """Create configuration data
 
     The generic signature *pos, **kws can will be resolved into a configuration.
@@ -121,53 +121,53 @@
 
     A: No arguments does not satisfy the configuration:
 
-        >>> argumentsToConfiguration(IAnyConfiguration)
+        >>> parameterToConfiguration(IAnyConfiguration)
         Traceback (most recent call last):
         ...
         TypeError: __init__ requires 'a, d' of 'IAnyConfiguration'.
 
     B: Provide the required as positionals:
 
-        >>> config = argumentsToConfiguration(IAnyConfiguration, u'a bla', u'd bla')
+        >>> config = parameterToConfiguration(IAnyConfiguration, u'a bla', u'd bla')
         >>> config.a, config.b, config.c, config.d
         (u'a bla', None, u'c default', u'd bla')
 
     C: Provide the required as positional and keyword:
 
-        >>> config = argumentsToConfiguration(IAnyConfiguration, u'a bla', d=u'd bla')
+        >>> config = parameterToConfiguration(IAnyConfiguration, u'a bla', d=u'd bla')
         >>> config.a, config.b, config.c, config.d
         (u'a bla', None, u'c default', u'd bla')
 
     D: Provide all required as keyword:
 
-        >>> config = argumentsToConfiguration(IAnyConfiguration, d=u'd bla', c=u'c bla', a=u'a bla')
+        >>> config = parameterToConfiguration(IAnyConfiguration, d=u'd bla', c=u'c bla', a=u'a bla')
         >>> config.a, config.b, config.c, config.d
         (u'a bla', None, u'c bla', u'd bla')
 
     E: You can also use an existing configuration as input:
 
-        >>> argumentsToConfiguration(IAnyConfiguration, config) == config
+        >>> parameterToConfiguration(IAnyConfiguration, config) == config
         True
 
 
     F: Provide the required as positional and keyword, do not messup the order otherwise
     a duplacted arguments error could occur:
 
-        >>> config = argumentsToConfiguration(IAnyConfiguration, u'a bla', d=u'd bla', c=u'c bla')
+        >>> config = parameterToConfiguration(IAnyConfiguration, u'a bla', d=u'd bla', c=u'c bla')
         >>> config.a, config.b, config.c, config.d
         (u'a bla', None, u'c bla', u'd bla')
 
-        >>> argumentsToConfiguration(IAnyConfiguration, u'd bla', a=u'd bla', c=u'c bla')
+        >>> parameterToConfiguration(IAnyConfiguration, u'd bla', a=u'd bla', c=u'c bla')
         Traceback (most recent call last):
         ...
         AttributeError: Duplicated arguments: a.
 
     G: Sometimes no arguments are allowed. This use case is indicated by a None key interface:
 
-        >>> argumentsToConfiguration(None) is None
+        >>> parameterToConfiguration(None) is None
         True
 
-        >>> argumentsToConfiguration(None, 'not allowed parameter')
+        >>> parameterToConfiguration(None, 'not allowed parameter')
         Traceback (most recent call last):
         ...
         AttributeError: No arguments allowed.

Modified: zope.generic/trunk/src/zope/generic/configuration/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/interfaces.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/configuration/interfaces.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -20,7 +20,6 @@
 
 from zope.app.event.interfaces import IModificationDescription
 from zope.app.event.interfaces import IObjectEvent
-from zope.app.i18n import ZopeMessageFactory as _
 from zope.app.location import ILocation
 from zope.interface import Interface
 from zope.interface import Attribute
@@ -30,6 +29,7 @@
 from zope.generic.keyface import IKeyfaceDescription
 
 
+
 class IConfigurable(Interface):
     """Provides an adapter to IConfigurations."""
 

Deleted: zope.generic/trunk/src/zope/generic/configuration/meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/meta.zcml	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/configuration/meta.zcml	2006-04-26 10:07:05 UTC (rev 67614)
@@ -1,15 +0,0 @@
-<configure
-    xmlns="http://namespaces.zope.org/zope"
-    xmlns:meta="http://namespaces.zope.org/meta">
-
-  <meta:directives namespace="http://namespaces.zope.org/generic">
-
-    <meta:directive
-        name="configurationAdapter"
-        schema=".metadirectives.IConfigurationAdapterDirective"
-        handler=".metaconfigure.configurationAdapterDirective"
-        />
-
-  </meta:directives>
-
-</configure>

Deleted: zope.generic/trunk/src/zope/generic/configuration/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/metaconfigure.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/configuration/metaconfigure.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -1,46 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005, 2006 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.
-#
-##############################################################################
-
-"""
-$Id$
-"""
-
-__docformat__ = 'restructuredtext'
-
-from zope.app.component.contentdirective import ClassDirective
-from zope.app.component.metaconfigure import adapter
-
-from zope.generic.configuration.adapter import ConfigurationAdapterClass
-
-
-
-def configurationAdapterDirective(_context, keyface, provides, class_=None, writePermission=None, readPermission=None):
-    """Provide a generic configuration adatper."""
-
-    # we will provide a generic adapter class
-    if class_ is None:
-        class_ = ConfigurationAdapterClass(provides)
-
-    # register class
-    class_directive = ClassDirective(_context, class_)
-    if writePermission:
-        class_directive.require(_context, permission=writePermission, set_schema=[keyface])
-
-    if readPermission:
-        class_directive.require(_context, permission=readPermission, interface=[keyface])
-
-    # register adapter
-    adapter(_context, factory=[class_], provides=provides, 
-            for_=[keyface], permission=None, name='', trusted=True, 
-            locate=False)

Deleted: zope.generic/trunk/src/zope/generic/configuration/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/metadirectives.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/configuration/metadirectives.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -1,63 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005, 2006 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.
-#
-##############################################################################
-
-"""
-$Id$
-"""
-
-__docformat__ = 'restructuredtext'
-
-from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.security.fields import Permission
-from zope.configuration.fields import GlobalInterface
-from zope.configuration.fields import GlobalObject
-from zope.interface import Interface
-
-
-
-class IConfigurationAdapterDirective(Interface):
-    """Provide an adapter to a certain configuration."""
-
-    keyface = GlobalInterface(
-        title=_('Key Interface3'),
-        description=_('Configuration interface defining adapter interface.'),
-        required=True
-        )
-
-    provides = GlobalInterface(
-        title=_('Configuration Key Interface3'),
-        description=_('Configuration interface defining adapter interface.'),
-        required=True
-        )
-
-    class_ = GlobalObject(
-        title=_('Adapter class'),
-        description=_('If not declared a generic implementation will be used.'),
-        required=False
-        )
-
-    writePermission = Permission(
-        title=_('Write Permission'),
-        description=_('Specifies the permission by id that will be required ' +
-            ' to mutate the attributes and methods specified.'),
-        required=False,
-        )
-
-    readPermission = Permission(
-        title=_('Read Permission'),
-        description=_('Specifies the permission by id that will be required ' +
-            ' to accessthe attributes and methods specified.'),
-        required=False,
-        )
-

Modified: zope.generic/trunk/src/zope/generic/configuration/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/testing.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/configuration/testing.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -20,7 +20,6 @@
 
 import zope.app.testing.placelesssetup
 from zope.component import provideAdapter
-from zope.configuration.xmlconfig import XMLConfig
 from zope.interface import Interface
 from zope.schema import TextLine
 
@@ -76,10 +75,6 @@
     provideAdapter(zope.generic.configuration.adapter.AttributeConfigurations,
         provides=IConfigurations)
 
-    # register the directive of this package
-    import zope.generic.configuration
-    XMLConfig('meta.zcml', zope.generic.configuration)()
-
 def tearDown(doctest=None):
     pass
 

Deleted: zope.generic/trunk/src/zope/generic/configuration/zope.generic.configuration-meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/zope.generic.configuration-meta.zcml	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/configuration/zope.generic.configuration-meta.zcml	2006-04-26 10:07:05 UTC (rev 67614)
@@ -1,5 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope">
-
-  <include package="zope.generic.configuration" file="meta.zcml" />
-
-</configure>

Added: zope.generic/trunk/src/zope/generic/factory/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/factory/DEPENDENCIES.cfg	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/factory/DEPENDENCIES.cfg	2006-04-26 10:07:05 UTC (rev 67614)
@@ -0,0 +1,12 @@
+zope.app.component
+zope.app.event
+zope.app.testing
+zope.component
+zope.configuration
+zope.event
+zope.generic.configuration
+zope.generic.directlyprovides
+zope.generic.informationprovider
+zope.generic.keyface
+zope.generic.operation
+zope.generic.testing
\ No newline at end of file


Property changes on: zope.generic/trunk/src/zope/generic/factory/DEPENDENCIES.cfg
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: zope.generic/trunk/src/zope/generic/factory/factory.py
===================================================================
--- zope.generic/trunk/src/zope/generic/factory/factory.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/factory/factory.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -23,7 +23,7 @@
 from zope.app.event.objectevent import ObjectCreatedEvent
 from zope.interface import alsoProvides
 
-from zope.generic.configuration.api import argumentsToConfiguration
+from zope.generic.configuration.api import parameterToConfiguration
 from zope.generic.configuration.api import configuratonToDict
 from zope.generic.directlyprovides.api import updateDirectlyProvided
 from zope.generic.informationprovider.api import getInformationProvider
@@ -235,7 +235,7 @@
         config = self.__config
         mode = self.__mode
         if config and config.input:
-            new_kws = configuratonToDict(argumentsToConfiguration(config.input, *pos, **kws), all=True)
+            new_kws = configuratonToDict(parameterToConfiguration(config.input, *pos, **kws), all=True)
             instance = self._callable(**new_kws)
         
         elif not pos and not kws:
@@ -263,7 +263,7 @@
         if self.__storeInput and config:
             input = config.input
             if input:
-                configuration = argumentsToConfiguration(input, *pos, **kws)
+                configuration = parameterToConfiguration(input, *pos, **kws)
                 provideInformation(instance, input, configuration)
 
         # invoke initializer operations

Modified: zope.generic/trunk/src/zope/generic/informationprovider/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/DEPENDENCIES.cfg	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/informationprovider/DEPENDENCIES.cfg	2006-04-26 10:07:05 UTC (rev 67614)
@@ -1,5 +1,3 @@
-zope.app.annotation
-zope.app.component
 zope.app.testing
 zope.component
 zope.configuration
@@ -8,4 +6,5 @@
 zope.generic.keyface
 zope.generic.testing
 zope.interface
+zope.schema
 zope.testing
\ No newline at end of file

Modified: zope.generic/trunk/src/zope/generic/informationprovider/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/base.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/informationprovider/base.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -21,7 +21,6 @@
 from zope.app.annotation import IAnnotations
 from zope.app.annotation import IAttributeAnnotatable
 from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.i18n import ZopeMessageFactory as _
 from zope.interface import alsoProvides
 from zope.interface import implements
 

Modified: zope.generic/trunk/src/zope/generic/informationprovider/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/interfaces.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/informationprovider/interfaces.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -18,7 +18,6 @@
 
 __docformat__ = 'restructuredtext'
 
-from zope.app.i18n import ZopeMessageFactory as _
 from zope.interface import alsoProvides
 
 from zope.generic.keyface import IKeyfaceType

Modified: zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -25,7 +25,6 @@
 from zope.interface import alsoProvides
 
 from zope.generic.configuration import IConfigurations
-from zope.generic.configuration.api import ConfigurationData
 from zope.generic.keyface.api import toDescription
 from zope.generic.keyface.api import toDottedName
 

Modified: zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -82,8 +82,8 @@
         )
 
     key = DottedName(
-        title=_('Interface'),
-        description=_('Interface referencing a configuraiton.'),
+        title=_('Annotation key'),
+        description=_('Annotation key referencing an annotation.'),
         required=False
         )
 

Modified: zope.generic/trunk/src/zope/generic/informationprovider/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/testing.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/informationprovider/testing.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -24,7 +24,6 @@
 import zope.generic.configuration.testing
 import zope.generic.directlyprovides.testing
 import zope.generic.keyface.testing
-import zope.generic.informationprovider.testing
 import zope.generic.testing.testing
 
 ################################################################################

Modified: zope.generic/trunk/src/zope/generic/keyface/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/keyface/base.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/keyface/base.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -21,7 +21,6 @@
 from zope.app.i18n import ZopeMessageFactory as _
 from zope.interface import implements
 
-from zope.generic.keyface import IAttributeKeyfaced
 from zope.generic.keyface import IKeyface
 from zope.generic.keyface import IKeyfaceDescription
 

Modified: zope.generic/trunk/src/zope/generic/operation/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/README.txt	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/operation/README.txt	2006-04-26 10:07:05 UTC (rev 67614)
@@ -26,11 +26,11 @@
     ...    """A possible output declaration for any operation."""
     ...    b = TextLine()
 
-    >>> from zope.generic.configuration.api import argumentsToConfiguration
+    >>> from zope.generic.configuration.api import parameterToConfiguration
     >>> from zope.generic.configuration.api import ConfigurationData
 
     >>> def anyOperation(context, *pos, **kws):
-    ...     input = argumentsToConfiguration(IAnyInput, *pos, **kws)
+    ...     input = parameterToConfiguration(IAnyInput, *pos, **kws)
     ...     print 'Any input: a=%s, b=%s, c=%s.' % (input.a, input.b, input.c)
     ...     print 'Operate on *%s*.' % context
     ...     return ConfigurationData(IAnyOutput, {'b': u'b operated'})
@@ -119,7 +119,7 @@
 
     >>> def setupPAUOperation(context, *pos, **kws):
     ...     print 'Public operation: setupPAUOperation'
-    ...     input = argumentsToConfiguration(IPAUConfig, *pos, **kws)
+    ...     input = parameterToConfiguration(IPAUConfig, *pos, **kws)
     ...     print 'Pau input: a=%s.' % (input.a)
 
     >>> registerDirective('''
@@ -181,7 +181,7 @@
 
     >>> def inputToConfigurations(context, *pos, **kws):
     ...    print 'Private operation: inputToConfigurations'
-    ...    input = argumentsToConfiguration(IComplexConfig, *pos, **kws)
+    ...    input = parameterToConfiguration(IComplexConfig, *pos, **kws)
     ...    provideInformation(context, IAnyInput, {'a': input.any})
     ...    provideInformation(context, IPAUConfig, {'a': input.pau})
 

Modified: zope.generic/trunk/src/zope/generic/operation/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/base.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/operation/base.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -23,7 +23,7 @@
 
 from zope.generic.keyface import IAttributeKeyfaced
 from zope.generic.keyface.api import Keyface
-from zope.generic.configuration.api import argumentsToConfiguration
+from zope.generic.configuration.api import parameterToConfiguration
 
 from zope.generic.operation import IOperation
 from zope.generic.operation import IPrivateOperation
@@ -64,7 +64,7 @@
 
     def __call__(self, context, *pos, **kws):
         """Invoke operation in the listed order."""
-        last_output = argumentsToConfiguration(self._input, *pos, **kws)
+        last_output = parameterToConfiguration(self._input, *pos, **kws)
         for operation in self._operations:
             if last_output is not None:
                 last_output = operation(context, last_output)

Modified: zope.generic/trunk/src/zope/generic/type/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/type/DEPENDENCIES.cfg	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/type/DEPENDENCIES.cfg	2006-04-26 10:07:05 UTC (rev 67614)
@@ -1,19 +1,18 @@
 persistent
 zope.app.annotation
-zope.app.component
 zope.app.container
 zope.app.folder
-zope.app.location
-zope.app.security
 zope.app.testing
 zope.component
 zope.configuration
+zope.generic.adapter
 zope.generic.configuration
 zope.generic.directlyprovides
+zope.generic.factory
 zope.generic.informationprovider
 zope.generic.keyface
+zope.generic.operation
 zope.generic.testing
 zope.interface
 zope.schema
-zope.security
-zope.testing
+zope.testing
\ No newline at end of file

Modified: zope.generic/trunk/src/zope/generic/type/EXAMPLE.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/type/EXAMPLE.txt	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/type/EXAMPLE.txt	2006-04-26 10:07:05 UTC (rev 67614)
@@ -145,6 +145,7 @@
     ...        class='zope.generic.type.api.Object'
     ...        input='example.IArticleInitializationConfiguration'
     ...        operations='example.articleInitializer'
+    ...        storeInput='True'
     ...    />
     ...    <information
     ...        keyface='example.ITextConfig'

Modified: zope.generic/trunk/src/zope/generic/type/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/type/README.txt	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/type/README.txt	2006-04-26 10:07:05 UTC (rev 67614)
@@ -50,8 +50,8 @@
     ...     keyface="example.IFooMarker"
     ...     label='Foo Type' hint='Bla bla bla.'
     ...     >
-    ...    <factory
-    ...        class='zope.generic.type.api.Object' />
+    ...    <factory class='zope.generic.type.api.Object'
+    ...        />
     ... </generic:type>
     ... ''')
 
@@ -163,14 +163,16 @@
     ...        class='zope.generic.type.api.Object'
     ...        input='example.IOtherConfiguration'
     ...        operations='example.barInitializer'
-    ...    />
+    ...        storeInput='True'
+    ...        />
     ...	   <information
     ...	       keyface='example.IAnyConfiguration'
     ...        configuration='example.typedata'
-    ...	   />
-    ...    <configurationAdapter
-    ...        keyface='example.IAnyConfiguration'
-    ...       />
+    ...	       />
+    ...    <adapter
+    ...        provides='example.IAnyConfiguration'
+    ...        acquire='True'
+    ...        />
     ... </generic:type>
     ... ''')
 

Modified: zope.generic/trunk/src/zope/generic/type/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/base.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/type/base.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -29,7 +29,6 @@
 
 from zope.generic.directlyprovides.api import provides
 from zope.generic.directlyprovides.api import UpdateProvides
-from zope.generic.directlyprovides.api import updateDirectlyProvided
 
 from zope.generic.type import IGenericTyped
 

Modified: zope.generic/trunk/src/zope/generic/type/meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/type/meta.zcml	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/type/meta.zcml	2006-04-26 10:07:05 UTC (rev 67614)
@@ -21,8 +21,8 @@
           />
 
       <meta:subdirective
-          name="configurationAdapter"
-          schema=".metadirectives.IConfigurationAdapterSubdirective"
+          name="adapter"
+          schema=".metadirectives.IAdapterSubdirective"
           />
 
     </meta:complexDirective>

Modified: zope.generic/trunk/src/zope/generic/type/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/metaconfigure.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/type/metaconfigure.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -18,61 +18,17 @@
 
 __docformat__ = 'restructuredtext'
 
-from types import ModuleType
+from zope.configuration.exceptions import ConfigurationError
 
-from zope.app.component.contentdirective import ClassDirective
-from zope.app.component.metaconfigure import adapter
-
-from zope.generic.configuration.api import ConfigurationAdapterClass
-from zope.generic.configuration.api import ConfigurationAdapterProperty
+from zope.generic.adapter.metaconfigure import adapterDirective
 from zope.generic.factory.metaconfigure import factoryDirective
-from zope.generic.informationprovider.api import provideInformation
 from zope.generic.informationprovider.metaconfigure import InformationProviderDirective
 
 from zope.generic.type import ITypeInformation
 from zope.generic.type import ITypeType
-from zope.generic.type.helper import queryTypeConfiguration
-from zope.generic.type.helper import queryTypeInformation
 
 
 
-def provideTypeConfiguration(keyface, configuration, data):
-    """Set configuration data into the context."""
-
-    info = queryTypeInformation(keyface)
-    provideInformation(info, configuration, data)
-
-
-
-_marker = object()
-
-class _TypeConfigurationAdapterProperty(ConfigurationAdapterProperty):
-    """Lookup type informations."""
-
-    def __get__(self, inst, klass):
-        if inst is None:
-            return self
-
-        configurations = inst.__configurations__
-        keyface = inst.__keyface__
-        context = inst.__context__
-
-        configuration = inst.__keyface__(configurations, None)
-        if configuration is None:
-            # Try to evaluate a type configuration
-            configuration = queryTypeConfiguration(context, keyface)
-
-        value = getattr(configuration, self._name, _marker)
-        if value is _marker:
-            field = self._field.bind(inst)
-            value = getattr(field, 'default', _marker)
-            if value is _marker:
-                raise AttributeError(self._name)
-
-        return value
-
-
-
 class TypeDirective(InformationProviderDirective):
     """Provide a new logical type."""
 
@@ -86,29 +42,24 @@
         super(TypeDirective, self).__init__(_context, keyface, registry, label, hint)
 
     def factory(self, _context, class_, operations=(), input=None,
-                providesKeyface=True, notifyCreated=True, storeInput=True):
+                providesKeyface=True, notifyCreated=False, storeInput=False):
         """Add factory."""
         factoryDirective(_context, self._keyface, class_, None, operations, input,
                      providesKeyface, notifyCreated, storeInput,
                      self._label, self._hint)
 
 
-    def configurationAdapter(self, _context, keyface, class_=None, writePermission=None, readPermission=None):
-        """Provide a generic configuration adatper."""
+    def adapter(self, _context, provides, class_=None, writePermission=None, 
+                readPermission=None, attributes=None, set_attributes=None, 
+                key=None, informationProviders=None, acquire=False):
+        """Provide a generic adatper for the key interface."""
+        
+        if informationProviders and acquire:
+            raise ConfigurationError('Use informationsProviders or acquire attriubte.')
 
-        # we will provide a generic adapter class
-        if class_ is None:
-            class_ = ConfigurationAdapterClass(keyface, (), _TypeConfigurationAdapterProperty)
+        if acquire:
+            informationProviders = [ITypeInformation]
 
-        # register class
-        class_directive = ClassDirective(_context, class_)
-        if writePermission:
-            class_directive.require(_context, permission=writePermission, set_schema=[keyface])
-
-        if readPermission:
-            class_directive.require(_context, permission=readPermission, interface=[keyface])
-
-        # register adapter
-        adapter(self._context, factory=[class_], provides=keyface, 
-                for_=[self._keyface], permission=None, name='', trusted=True, 
-                locate=False)
+        adapterDirective(_context, provides, [self._keyface], class_, 
+                     writePermission, readPermission, attributes,
+                     set_attributes, key, informationProviders,)
\ No newline at end of file

Modified: zope.generic/trunk/src/zope/generic/type/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/metadirectives.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/type/metadirectives.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -19,12 +19,9 @@
 __docformat__ = 'restructuredtext'
 
 from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.security.fields import Permission
 from zope.configuration.fields import Bool
-from zope.configuration.fields import GlobalInterface
-from zope.configuration.fields import GlobalObject
-from zope.interface import Interface
 
+from zope.generic.adapter.metadirectives import IOthersAdapterDirective
 from zope.generic.factory.metadirectives import IBaseFactoryDirective
 from zope.generic.informationprovider.metadirectives import IBaseInformationProviderDirective
 from zope.generic.operation.metadirectives import IBaseOperationDirective
@@ -42,34 +39,22 @@
 class IFactorySubdirective(IBaseFactoryDirective, IBaseOperationDirective):
     """Provide an factory for the type."""
 
-
-
-class IConfigurationAdapterSubdirective(Interface):
-    """Provide an adapter to a certain configuration."""
-
-    keyface = GlobalInterface(
-        title=_('Configuration Key Interface3'),
-        description=_('Configuration interface defining adapter interface.'),
-        required=True
+    providesKeyface = Bool(
+        title=_('Provides Keyface'),
+        description=_('If the class does not implement the key interface '
+                      'directly provide it to the instances '
+                      'before initalization.'),
+        required=False,
+        default=True
         )
 
-    class_ = GlobalObject(
-        title=_('Adapter class'),
-        description=_('If not declared a generic implementation will be used.'),
-        required=False
-        )
 
-    writePermission = Permission(
-        title=_('Write Permission'),
-        description=_('Specifies the permission by id that will be required ' +
-            ' to mutate the attributes and methods specified.'),
-        required=False,
-        )
+class IAdapterSubdirective(IOthersAdapterDirective):
+    """Provide an adapter for the key interface."""
 
-    readPermission = Permission(
-        title=_('Read Permission'),
-        description=_('Specifies the permission by id that will be required ' +
-            ' to accessthe attributes and methods specified.'),
+    acquire = Bool(
+        title=_('Acquire Type Information'),
+        description=_('If selected the type information are invoked.'),
         required=False,
-        )
-
+        default=False
+        )
\ No newline at end of file

Modified: zope.generic/trunk/src/zope/generic/type/tests.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/tests.py	2006-04-26 08:21:40 UTC (rev 67613)
+++ zope.generic/trunk/src/zope/generic/type/tests.py	2006-04-26 10:07:05 UTC (rev 67614)
@@ -37,7 +37,7 @@
                              tearDown=testing.placelesssetup.tearDown,
                              globs={'component': component, 'interface': interface,
                              'registerDirective': registerDirective,
-                             'testing': testing},
+                             'testing': testing, 'api': api},
                              optionflags=doctest.NORMALIZE_WHITESPACE+
                                             doctest.ELLIPSIS),
         doctest.DocFileSuite('EXAMPLE.txt',
@@ -45,7 +45,7 @@
                              tearDown=testing.placelesssetup.tearDown,
                              globs={'component': component, 'interface': interface,
                              'schema': schema, 'registerDirective': registerDirective,
-                             'testing': testing},
+                             'testing': testing, 'api': api},
                              optionflags=doctest.NORMALIZE_WHITESPACE+
                                             doctest.ELLIPSIS),
         ))



More information about the Checkins mailing list