[Checkins] SVN: zope.generic/trunk/src/zope/generic/ factor configuration and informationprovider stuff out of .component into .configuration und .informationprovider.

Dominik Huber dominik.huber at perse.ch
Thu Apr 20 10:08:02 EDT 2006


Log message for revision 67173:
  factor configuration and informationprovider stuff out of .component into .configuration und .informationprovider.

Changed:
  D   zope.generic/trunk/src/zope/generic/component/
  A   zope.generic/trunk/src/zope/generic/configuration/
  A   zope.generic/trunk/src/zope/generic/configuration/DEPENDENCIES.cfg
  A   zope.generic/trunk/src/zope/generic/configuration/PUBLICATION.cfg
  A   zope.generic/trunk/src/zope/generic/configuration/README.txt
  A   zope.generic/trunk/src/zope/generic/configuration/SETUP.cfg
  A   zope.generic/trunk/src/zope/generic/configuration/__init__.py
  A   zope.generic/trunk/src/zope/generic/configuration/adapter.py
  A   zope.generic/trunk/src/zope/generic/configuration/api.py
  A   zope.generic/trunk/src/zope/generic/configuration/base.py
  A   zope.generic/trunk/src/zope/generic/configuration/configure.zcml
  A   zope.generic/trunk/src/zope/generic/configuration/event.py
  A   zope.generic/trunk/src/zope/generic/configuration/helper.py
  A   zope.generic/trunk/src/zope/generic/configuration/interfaces.py
  A   zope.generic/trunk/src/zope/generic/configuration/testing.py
  A   zope.generic/trunk/src/zope/generic/configuration/tests.py
  A   zope.generic/trunk/src/zope/generic/configuration/zope.generic.component-configure.zcml
  A   zope.generic/trunk/src/zope/generic/configuration/zope.generic.configuration-configure.zcml
  U   zope.generic/trunk/src/zope/generic/directlyprovides/DEPENDENCIES.cfg
  A   zope.generic/trunk/src/zope/generic/informationprovider/
  A   zope.generic/trunk/src/zope/generic/informationprovider/DEPENDENCIES.cfg
  A   zope.generic/trunk/src/zope/generic/informationprovider/NEW_README.txt
  A   zope.generic/trunk/src/zope/generic/informationprovider/PUBLICATION.cfg
  A   zope.generic/trunk/src/zope/generic/informationprovider/README.txt
  A   zope.generic/trunk/src/zope/generic/informationprovider/SETUP.cfg
  A   zope.generic/trunk/src/zope/generic/informationprovider/__init__.py
  A   zope.generic/trunk/src/zope/generic/informationprovider/api.py
  A   zope.generic/trunk/src/zope/generic/informationprovider/base.py
  A   zope.generic/trunk/src/zope/generic/informationprovider/configure.zcml
  A   zope.generic/trunk/src/zope/generic/informationprovider/interfaces.py
  A   zope.generic/trunk/src/zope/generic/informationprovider/meta.zcml
  A   zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py
  A   zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py
  A   zope.generic/trunk/src/zope/generic/informationprovider/testing.py
  A   zope.generic/trunk/src/zope/generic/informationprovider/tests.py
  A   zope.generic/trunk/src/zope/generic/informationprovider/zope.generic.informationprovider-configure.zcml
  A   zope.generic/trunk/src/zope/generic/informationprovider/zope.generic.informationprovider-meta.zcml
  U   zope.generic/trunk/src/zope/generic/keyface/DEPENDENCIES.cfg
  A   zope.generic/trunk/src/zope/generic/keyface/PUBLICATION.cfg
  U   zope.generic/trunk/src/zope/generic/keyface/README.txt
  U   zope.generic/trunk/src/zope/generic/keyface/api.py
  A   zope.generic/trunk/src/zope/generic/keyface/helper.py
  U   zope.generic/trunk/src/zope/generic/keyface/interfaces.py
  A   zope.generic/trunk/src/zope/generic/keyface/meta.zcml
  A   zope.generic/trunk/src/zope/generic/keyface/metaconfigure.py
  A   zope.generic/trunk/src/zope/generic/keyface/metadirectives.py
  U   zope.generic/trunk/src/zope/generic/keyface/testing.py
  A   zope.generic/trunk/src/zope/generic/keyface/zope.generic.keyface-meta.zcml
  A   zope.generic/trunk/src/zope/generic/operation/DEPENDENCIES.cfg
  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/operation/helper.py
  U   zope.generic/trunk/src/zope/generic/operation/interfaces.py
  U   zope.generic/trunk/src/zope/generic/operation/metaconfigure.py
  U   zope.generic/trunk/src/zope/generic/operation/metadirectives.py
  U   zope.generic/trunk/src/zope/generic/operation/testing.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/adapter.py
  U   zope.generic/trunk/src/zope/generic/type/base.py
  U   zope.generic/trunk/src/zope/generic/type/configure.zcml
  U   zope.generic/trunk/src/zope/generic/type/helper.py
  U   zope.generic/trunk/src/zope/generic/type/interfaces.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/testing.py

-=-
Added: zope.generic/trunk/src/zope/generic/configuration/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/DEPENDENCIES.cfg	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/DEPENDENCIES.cfg	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,14 @@
+BTrees
+persistent
+zope.app.event
+zope.app.location
+zope.app.testing
+zope.component
+zope.configuration
+zope.event
+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/configuration/DEPENDENCIES.cfg
___________________________________________________________________
Name: svn:keywords
   + Id

Added: zope.generic/trunk/src/zope/generic/configuration/PUBLICATION.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/PUBLICATION.cfg	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/PUBLICATION.cfg	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: zope.generic.configuration
+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/configuration/PUBLICATION.cfg
___________________________________________________________________
Name: svn:keywords
   + Id

Added: zope.generic/trunk/src/zope/generic/configuration/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/README.txt	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/README.txt	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,206 @@
+=====================
+Generic Configuration
+=====================
+
+The configurations mechansim works similar to the annotations mechansim, but 
+references a single configuration (annotation) by its corresponding 
+configuration schema (regular interfac-based schema see zope.schema). 
+Such a configuration associates data and its corresponding schema. That means
+the configuration data provides the related schema and you can allways lookup
+dedicated configuration data by its configuration schema.
+
+The annotations mechanism is well-known and documented (zope.annotations).
+
+
+Configurations
+---------------
+
+Configurations is a container of configuration data. Configuration data are
+defined by an schema which is providing IConfigurationType. The configuration
+data itself has to provide the schema that is used to reference it.
+
+    >>> from zope.schema import TextLine
+        
+    >>> class IMyConfiguration(interface.Interface):
+    ...     my = TextLine(title=u'My')
+
+    >>> registerDirective('''
+    ... <generic:keyface
+    ...     keyface="example.IMyConfiguration"
+    ...     type="zope.generic.configuration.IConfigurationType"
+    ...     />
+    ... ''') 
+
+    >>> from zope.generic.configuration.api import IConfigurationType
+    >>> IConfigurationType.providedBy(IMyConfiguration)
+    True
+ 
+Regularly local configurations are provided by objects marked with
+IAttributeConfigurations automatically:
+
+    >>> from zope.interface import implements
+    >>> from zope.generic.configuration.api import IAttributeConfigurable
+
+    >>> class Foo(object):
+    ...    implements(IAttributeConfigurable)
+
+    >>> foo = Foo()
+    >>> IAttributeConfigurable.providedBy(foo)
+    True
+
+Now you can adapt you to IConfigurations:
+
+    >>> from zope.generic.configuration.api import IConfigurations
+
+    >>> configurations = IConfigurations(foo)
+    >>> IConfigurations.providedBy(configurations)
+    True
+
+At the beginning the IConfigurations storage does not exists:
+
+    >>> configurations.__nonzero__()
+    False
+
+Configuration data will be stored under an key interface within the
+configurations. Such a configuration schema defines its configuration
+data:
+
+    >>> from zope.interface import Interface
+    >>> from zope.schema import TextLine
+    
+    >>> class IFooConfiguration(Interface):
+    ...    foo = TextLine(title=u'Foo')
+    ...    optional = TextLine(title=u'Optional', required=False, default=u'Bla')
+
+The configuration schema is a regular schema, but it has to be typed
+by IConfigurationType (Regularly done by the configuration directive):
+
+    >>> from zope.interface import directlyProvides
+
+    >>> directlyProvides(IFooConfiguration, IConfigurationType)
+    >>> IConfigurationType.providedBy(IFooConfiguration)
+    True
+
+The configurations provides a regular dictionary api by the UserDictMixin
+(like AttributeAnnotations). This mixin bases on the following methods:
+
+    >>> configurations[IFooConfiguration]
+    Traceback (most recent call last):
+    ...
+    KeyError: <InterfaceClass example.IFooConfiguration>
+
+    >>> del configurations[IFooConfiguration]
+    Traceback (most recent call last):
+    ...
+    KeyError: <InterfaceClass example.IFooConfiguration>
+
+    >>> configurations.keys()
+    []
+
+... if a value might be set to the configurations it must provide the 
+configuration schema itself. This key interface must provide IConfigurationType:
+
+    >>> class IBarConfiguration(Interface):
+    ...    bar = TextLine(title=u'Bar')
+
+    >>> configurations[IBarConfiguration] = object()
+    Traceback (most recent call last):
+    ...
+    KeyError: 'Interface key IBarConfiguration does not provide IConfigurationType.'
+
+    >>> configurations[IFooConfiguration] = object()
+    Traceback (most recent call last):
+    ...
+    ValueError: Value does not provide IFooConfiguration.
+
+Furthermore there is an update method that can be used to update a specific
+configuration. This method can be only used if a configuration already exists:
+
+    >>> configurations.update(IFooConfiguration, {'foo': u'Foo!'})
+    Traceback (most recent call last):
+    ...
+    KeyError: <InterfaceClass example.IFooConfiguration>
+
+You can create valid configuration data using the generic ConfigurationData
+implementation and a configuration schema:
+
+    >>> from zope.generic.configuration.api import ConfigurationData
+
+    >>> data = ConfigurationData(IFooConfiguration, {'foo': u'Foo!'})
+
+    >>> configurations[IFooConfiguration] = data
+
+The setting of the configuration is notified by a object configured event if 
+the parent has a location an the parent's parent is not None:
+
+    >>> from zope.app.event.tests.placelesssetup import getEvents, clearEvents
+    >>> from zope.generic.configuration.api import IObjectConfiguredEvent
+
+    >>> events = getEvents()
+    >>> len(events)
+    0
+
+    >>> from zope.app.location import Location
+    >>> parent = Location()
+    >>> configurations.__parent__ = parent
+    
+    >>> configurations[IFooConfiguration] = data
+    >>> events = getEvents()
+    >>> len(events)
+    0
+
+    >>> parent.__parent__ = Location()
+    >>> configurations[IFooConfiguration] = data
+    >>> events = getEvents()
+    >>> len(events)
+    1
+
+    >>> event = events.pop()
+    >>> IObjectConfiguredEvent.providedBy(event)
+    True
+    >>> [(key.__name__, value) for key, value in event.items()]
+    [('IFooConfiguration', {'foo': u'Foo!', 'optional': u'Bla'})]
+
+If the configuration data is set the first time an oobtree storage is set
+to the __configurations__ attribute of the context:
+
+    >>> configurations.__nonzero__()
+    True
+
+    >>> IFooConfiguration in configurations
+    True
+
+    >>> configurations[IFooConfiguration] == data
+    True
+
+    >>> [iface.__name__ for iface in configurations.keys()]
+    ['IFooConfiguration']
+
+You should update a configuration using the update method instead of setting
+new configuration data. If the change differs from the configuration an object
+configuration modified event is notify else not:
+
+    >>> clearEvents()
+    >>> configurations.update(IFooConfiguration, {'foo': u'Bar!'})
+    >>> events = getEvents()
+    >>> len(events)
+    1
+    >>> event = events.pop()
+    >>> [(key.__name__, value) for key, value in event.items()]
+    [('IFooConfiguration', {'foo': u'Bar!'})]
+
+Also the deletion is notified by an empty dict:
+
+    >>> clearEvents()
+
+    >>> del configurations[IFooConfiguration]
+    >>> IFooConfiguration in configurations
+    False
+
+    >>> events = getEvents()
+    >>> len(events)
+    1
+    >>> event = events.pop()
+    >>> [(key.__name__, value) for key, value in event.items()]
+    [('IFooConfiguration', {})]
+


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

Added: zope.generic/trunk/src/zope/generic/configuration/SETUP.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/SETUP.cfg	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/SETUP.cfg	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,3 @@
+<data-files zopeskel/etc/package-includes>
+  zope.generic.configuration-*.zcml
+</data-files>
\ No newline at end of file


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

Added: zope.generic/trunk/src/zope/generic/configuration/__init__.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/__init__.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/__init__.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -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.configuration.interfaces import *
\ No newline at end of file


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

Added: zope.generic/trunk/src/zope/generic/configuration/adapter.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/adapter.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/adapter.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,143 @@
+##############################################################################
+#
+# 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 BTrees.OOBTree import OOBTree
+import transaction
+from UserDict import DictMixin
+
+from zope.app.location import Location
+from zope.app.location.interfaces import ILocation
+from zope.component import adapts
+from zope.event import notify
+from zope.interface import implements
+
+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.event import Configuration
+from zope.generic.configuration.event import ObjectConfiguredEvent
+from zope.generic.configuration.helper import configuratonToDict
+
+
+
+class AttributeConfigurations(DictMixin, Location):
+    """Store configurations on an object within the __configurations__ attribute.
+
+    """
+
+    implements(IConfigurations)
+
+    adapts(IAttributeConfigurable)
+
+    def __init__(self, context):
+        self.context = context
+
+    def __nonzero__(self):
+        return bool(getattr(self.context, '__configurations__', 0))
+
+    def __conform__(self, keyface):
+        configurations = getattr(self.context, '__configurations__', None)
+        if configurations is None:
+            return None
+
+        else:
+            return configurations.get(toDottedName(keyface), None)
+
+    def __getitem__(self, keyface):
+        configurations = getattr(self.context, '__configurations__', None)
+        if configurations is None:
+            raise KeyError(keyface)
+
+        return configurations[toDottedName(keyface)]
+
+    def keys(self):
+        configurations = getattr(self.context, '__configurations__', None)
+        if configurations is None:
+            return []
+
+        return [toKeyface(iface) for iface in configurations.keys()]
+
+    def update(self, keyface, data):
+        current_config = self[keyface]
+
+        updated_data = {}
+        errors = []
+        
+        savepoint = transaction.savepoint()
+        try:
+            for name, value in data.items():
+                # raise attribute error
+                field = keyface[name]
+                if field.readonly:
+                    raise ValueError(name, 'Data is readonly.')
+                else:
+                    if value != getattr(current_config, name, field.missing_value):
+                        setattr(current_config, name, value)
+                        updated_data[name] = value
+
+            # notify update
+            parent = self.__parent__
+            if updated_data and ILocation.providedBy(parent) and parent.__parent__ is not None:
+                notify(ObjectConfiguredEvent(parent, 
+                    Configuration(keyface, updated_data)))
+
+        except:
+            savepoint.rollback()
+            raise
+
+    def __setitem__(self, keyface, value):
+        # preconditions
+        if not IConfigurationType.providedBy(keyface):
+            raise KeyError('Interface key %s does not provide %s.' % 
+                (keyface.__name__, IConfigurationType.__name__))
+
+        if not keyface.providedBy(value):
+            raise ValueError('Value does not provide %s.' % keyface.__name__)
+
+        # essentials
+        try:
+            configurations = self.context.__configurations__
+        except AttributeError:
+            configurations = self.context.__configurations__ = OOBTree()
+
+        data = configuratonToDict(keyface, value, all=True)
+        configurations[toDottedName(keyface)] = value
+        # notify setting
+        parent = self.__parent__
+        if ILocation.providedBy(parent) and parent.__parent__ is not None:
+            notify(ObjectConfiguredEvent(parent, 
+                Configuration(keyface, data)))
+
+    def __delitem__(self, keyface):
+        try:
+            configurations = self.context.__configurations__
+        except AttributeError:
+            raise KeyError(keyface)
+
+        del configurations[toDottedName(keyface)]
+        # notify deletion
+        # notify setting
+        parent = self.__parent__
+        if ILocation.providedBy(parent) and parent.__parent__ is not None:
+            notify(ObjectConfiguredEvent(parent, 
+                Configuration(keyface, {})))


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

Added: zope.generic/trunk/src/zope/generic/configuration/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/api.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/api.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,24 @@
+##############################################################################
+#
+# 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 *
+from zope.generic.configuration.adapter import AttributeConfigurations
+from zope.generic.configuration.base import ConfigurationData
+from zope.generic.configuration.helper import configuratonToDict


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

Added: zope.generic/trunk/src/zope/generic/configuration/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/base.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/base.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,179 @@
+##############################################################################
+#
+# 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 persistent import Persistent
+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
+from zope.schema.interfaces import IField
+
+from zope.generic.keyface import IAttributeKeyfaced
+from zope.generic.keyface import IKeyface
+from zope.generic.keyface.api import KeyfaceForAttributeKeyfaced
+
+from zope.generic.configuration import IConfigurationData
+from zope.generic.configuration import IConfigurations
+
+
+
+_marker = object()
+
+class ConfigurationData(Persistent):
+    """Generic configuration data.
+    
+    The generic configuration data implementation can be used to create
+    instances providing a certain configuration schema on the fly. This is done
+    only by a __getattr__ and a __setattr__ method that asserts the configuration
+    schema constraint.
+
+    We first have to define an example configuration schema:
+
+        >>> from zope.interface import Interface
+        >>> from zope.schema import TextLine
+        
+        >>> class IExampleConfiugrationSchema(Interface):
+        ...    foo = TextLine(title=u'Foo')
+        ...    fuu = TextLine(title=u'Fuu', required=False)
+        ...    fii = TextLine(title=u'Fii', required=False, readonly=True)
+
+    Create a corresponding configuration data:
+
+        >>> config_data = ConfigurationData(IExampleConfiugrationSchema, {'foo': u'Foo!'})
+        >>> IExampleConfiugrationSchema.providedBy(config_data)
+        True
+        >>> config_data.foo
+        u'Foo!'
+        >>> config_data.fuu
+        
+        >>> config_data.bar
+        Traceback (most recent call last):
+        ...
+        AttributeError: bar
+        
+        >>> config_data.fii = u'Bla bla'
+        Traceback (most recent call last):
+        ...
+        ValueError: ('fii', 'Data is readonly.')
+
+    If a relevant key is missed within the data a key error is raised:
+
+        >>> config_data = ConfigurationData(IExampleConfiugrationSchema, {})
+        Traceback (most recent call last):
+        ...
+        AttributeError: 'IExampleConfiugrationSchema' object has no attribute 'foo'.
+
+    The schema should not contain methods:
+
+        >>> class IBarConfiguration(Interface):
+        ...    bar = TextLine(title=u'Bar')
+        ...    def method(self):
+        ...        pass
+
+        >>> config_data = ConfigurationData(IBarConfiguration, {'bar': u'Bar!', 'method': u'Method!'})
+        >>> config_data.bar
+        u'Bar!'
+        >>> config_data.method
+        Traceback (most recent call last):
+        ...
+        RuntimeError: ('Data value is not a schema field', 'method')
+
+    The implementation provide an adapter to IKeyface by its __conform__
+    method:
+
+        >>> adapted = IKeyface(config_data)
+        >>> IKeyface.providedBy(adapted)
+        True
+
+        >>> adapted.keyface is IBarConfiguration
+        True
+  
+    """
+
+    implements(IAttributeKeyfaced, IConfigurationData)
+
+    def __init__(self, schema, data):
+        # preconditions
+        missedArguments = []
+        for name in schema:
+            if name not in data:
+                field = schema[name]
+                if field.required is True:
+                    missedArguments.append(name)
+        
+        if missedArguments:
+            raise AttributeError("'%s' object has no attribute '%s'." % (schema.__name__, ', '.join(missedArguments)))
+    
+        # essentials
+        self.__dict__['_ConfigurationData__data'] = PersistentDict(data)
+        self.__dict__['__keyface__'] = schema
+        directlyProvides(self, schema)
+
+    def __conform__(self, interface):
+        if interface is IKeyface:
+            return KeyfaceForAttributeKeyfaced(self)
+
+    def __getattr__(self, name):
+        # assert IAttributeKeyfaced
+        if name == '__keyface__':
+            return self.__dict__['__keyface__']
+
+        schema = self.__dict__['__keyface__']
+        data = self.__dict__['_ConfigurationData__data']
+        try:
+            field = schema[name]
+        except KeyError:
+            raise AttributeError(name)
+        else:
+            value = data.get(name, _marker)
+            if value is _marker:
+                value = getattr(field, 'default', _marker)
+                if value is _marker:
+                    raise RuntimeError('Data is missing', name)
+
+            if IMethod.providedBy(field):
+                if not IField.providedBy(field):
+                    raise RuntimeError('Data value is not a schema field', name)
+                v = lambda: value
+            else:
+                v = value
+            #setattr(self, name, v)
+            return v
+        raise AttributeError(name)
+
+    def __setattr__(self, name, value):
+
+        if not(name == '__provides__' or name in IPersistent):
+            schema = self.__dict__['__keyface__']
+            data = self.__dict__['_ConfigurationData__data']
+
+            try:
+                field = schema[name]
+            except KeyError:
+                raise AttributeError(name)
+            else:
+                if field.readonly is True:
+                    raise ValueError(name, 'Data is readonly.')
+            data[name] = value
+        else:
+            super(ConfigurationData, self).__setattr__(name, value)


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

Added: zope.generic/trunk/src/zope/generic/configuration/configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/configure.zcml	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/configure.zcml	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,28 @@
+<configure
+  xmlns="http://namespaces.zope.org/zope"
+  xmlns:generic="http://namespaces.zope.org/generic"
+  i18n_domain="zope">
+ 
+   <!-- attribute configurations -->
+  <class class=".adapter.AttributeConfigurations">
+    <require
+        permission="zope.Public"
+        interface=".IReadConfigurations"
+        />
+    <require
+        permission="zope.ManageContent"
+        interface=".IUpdateConfigurations"
+        />
+    <require
+        permission="zope.ManageSite"
+        interface=".IWriteConfigurations"
+        />
+  </class>
+
+  <adapter 
+  	  factory=".adapter.AttributeConfigurations"
+  	  provides="zope.generic.configuration.IConfigurations"
+  	  trusted="True"
+  	  />
+
+</configure>


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

Added: zope.generic/trunk/src/zope/generic/configuration/event.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/event.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/event.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,145 @@
+##############################################################################
+#
+# 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.event.objectevent import ObjectEvent
+from zope.interface import implements
+
+from zope.generic.configuration import IObjectConfiguredEvent
+from zope.generic.configuration import IConfigurationModificationDescription
+
+
+
+class Configuration(object) :
+    """Describes a single modified configuration.
+
+    A possible configuration schema:
+
+        >>> from zope.interface import Interface
+        >>> from zope.schema import TextLine
+        
+        >>> class IMyConfiguration(Interface):
+        ...     my = TextLine(title=u'My')
+
+    Check interface implementation:
+        
+        >>> description = Configuration(IMyConfiguration, {'my': u'Bla'})
+
+        >>> IConfigurationModificationDescription.providedBy(description)
+        True
+
+        >>> description.keyface == IMyConfiguration
+        True
+
+        >>> 'my' in description.data
+        True
+        >>> description.data.get('my')
+        u'Bla'
+
+    If no data argument is set, the data attribute will be set to an empty
+    dict, which implies that the configuration was deleted:
+
+        >>> description = Configuration(IMyConfiguration)
+        >>> description.keyface == IMyConfiguration
+        True
+
+        >>> description.data
+        {}
+
+    """
+
+    implements(IConfigurationModificationDescription)
+
+    def __init__(self, keyface, data=None) :
+        self.keyface = keyface
+        if data is not None:
+            self.data = data
+
+        else:
+            self.data = {}
+
+
+
+class ObjectConfiguredEvent(ObjectEvent):
+    """An object's configurations has been modified.
+        
+    A possible configuration schema:
+
+        >>> from zope.interface import Interface
+        >>> from zope.schema import TextLine
+                
+        >>> class IMyConfiguration(Interface):
+        ...     my = TextLine(title=u'My')
+        
+        >>> class IYourConfiguration(Interface):
+        ...     your = TextLine(title=u'Your')
+         
+        >>> class IRegularInterface(Interface):
+        ...    pass
+ 
+    A possible event:
+ 
+        >>> descriptions = []
+        >>> descriptions.append(Configuration(IMyConfiguration, {'my': u'Bla'}))
+        >>> descriptions.append(Configuration(IYourConfiguration))
+        >>> from zope.app.event.objectevent import Attributes
+        >>> descriptions.append(Attributes(IRegularInterface))
+        >>> context = object()
+        >>> event = ObjectConfiguredEvent(context, *descriptions)
+
+    There are two convenience function to introspect configuration modifications
+    specifically:
+
+        >>> len(event.descriptions) is 3
+        True
+
+        >>> items = event.items()
+        >>> len(items) is 2
+        True
+        >>> [(interface.__name__, data) for interface, data in items]
+        [('IMyConfiguration', {'my': u'Bla'}), ('IYourConfiguration', {})]
+
+        >>> event.get(IMyConfiguration)
+        {'my': u'Bla'}
+
+        >>> event.get(IYourConfiguration)
+        {}
+
+        >>> event.get(IRegularInterface, 'default')
+        'default'
+    """
+
+    implements(IObjectConfiguredEvent)
+
+    def __init__(self, object, *descriptions):
+        super(ObjectConfiguredEvent, self).__init__(object) 
+        self.descriptions = descriptions
+
+    def items(self):
+        return [(d.keyface, d.data) for d in self.descriptions 
+                   if IConfigurationModificationDescription.providedBy(d)]
+
+    def get(self, keyface, default=None):
+        result = [d.data for d in self.descriptions 
+                   if IConfigurationModificationDescription.providedBy(d) and d.keyface is keyface]
+        if result:
+            return result[0]
+
+        else:
+            return default


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

Added: zope.generic/trunk/src/zope/generic/configuration/helper.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/helper.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/helper.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,72 @@
+##############################################################################
+#
+# 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'
+
+
+_marker = object()
+
+def configuratonToDict(interface, configuration, all=False):
+    """Extract values from configuration to a dictionary.
+
+    First we have to specify a test configurtion interface:
+
+        >>> from zope.interface import Interface
+        >>> from zope.schema import TextLine
+        
+        >>> class IFooConfiguration(Interface):
+        ...    fo = TextLine(title=u'Fo')
+        ...    foo = TextLine(title=u'Foo', required=False)
+        ...    fooo = TextLine(title=u'Fooo', required=False, readonly=True, default=u'fooo bla')
+
+    Minimal data without defaults:
+
+        >>> from zope.generic.configuration.base import ConfigurationData
+        >>> configuration = ConfigurationData(IFooConfiguration, {'fo': 'fo bla'})
+        >>> configuratonToDict(IFooConfiguration, configuration)
+        {'fo': 'fo bla'}
+
+    Including defaults:
+        >>> configuratonToDict(IFooConfiguration, configuration, all=True)
+        {'fooo': u'fooo bla', 'foo': None, 'fo': 'fo bla'}
+
+    """
+    data = {}
+    for name in interface:
+        value = getattr(configuration, name, _marker)
+        field = interface[name]
+
+        if field.required is False:
+            if value is not _marker and value != field.default:
+               data[name] = value
+
+            elif value == field.default:
+                if all:
+                    data[name] = value
+
+            else:
+                if all:
+                    data[name] = field.default
+        
+        elif value is not _marker:
+            data[name] = value
+
+        else:
+            raise RuntimeError('Data is missing', name)
+
+    return data


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

Added: zope.generic/trunk/src/zope/generic/configuration/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/interfaces.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/interfaces.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,171 @@
+##############################################################################
+#
+# 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.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
+
+from zope.generic.keyface import IKeyfaced
+from zope.generic.keyface import IKeyfaceType
+from zope.generic.keyface import IKeyfaceDescription
+
+
+class IConfigurable(Interface):
+    """Provides an adapter to IConfigurations."""
+
+
+
+class IConfigurationType(IKeyfaceType):
+    """Mark a schema that is used for configuration."""
+
+
+
+class IConfigurationData(IKeyfaced):
+    """Marker for configuration data implementations."""
+
+
+
+class IReadConfigurations(Interface):
+    """Read configuration data or looku for a certain configuration shema."""
+
+    def __conform__(keyface):
+        """Invoke configuration data that are stored under the key interface.
+
+        Regularly the interface-key should provide configuration type.
+        If no value could be found None is returned.
+        """
+
+    def __nonzero__():
+        """Test whether there are any configurations at all."""
+
+    def __getitem__(keyface):
+        """Return the configuration data stored under key interface.
+
+        Raises a KeyError if the key interface is not found.
+        """
+
+    def keys(self):
+        """Return stored key interfaces."""
+
+
+
+class IUpdateConfigurations(Interface):
+    """Update configuration data."""
+
+    def update(keyface, data):
+        """Update the configuration data partially if nessecary.
+
+        data - dict providing keys and values corresponding to key interface.
+        
+        The data object itself will not be saved, only the values that
+        differs from the existing configuration data.
+        
+        A ValueError is raised if an read-only attribute/value should be set.
+
+        A AttributeError is raised if a not declared name should be set.
+
+        A KeyError is raise if there is no corresponding configuration available.
+        
+        A successfull update is notified by a ObjectConfiguredEvent if
+        any value of the configuration data got changed and the surrounding 
+        context (parent of the configurations) is providing ILocation.
+        """
+
+
+
+class IWriteConfigurations(Interface):
+    """Set or delete a configuration data."""
+
+    def __setitem__(keyface, configuration_data):
+        """Store a certain configuration data under the interface-key.
+
+        The interface key should provide IConfigurationType.
+
+        The configuration data has to provide the declared key interface. 
+        
+        Configuration data will be invoked by the __conform__ mechanism if
+        somebody try to adapt the configurations to corresponding key interface.
+        
+        A successfull setting is notified by a ObjectConfiguredEvent if
+        any value of the configuration data got changed and the surrounding 
+        context (parent of the configurations) is providing ILocation.
+        """
+
+    def __delitem__(keyface):
+        """Removes the configuration data stored under interface-key.
+
+        Raises a KeyError if the key interface is not found.
+
+        A successfull deletion is notified by a ObjectConfiguredEvent if
+        any value of the configuration data got changed and the surrounding 
+        context (parent of the configurations) is providing ILocation.
+        """
+
+
+
+class IConfigurations(IReadConfigurations, IUpdateConfigurations, 
+                      IWriteConfigurations, IConfigurable, ILocation):
+    """United configurations interfaces."""
+
+
+class IAttributeConfigurable(IConfigurable):
+    """Marker indicating that configurations can be stored on an attribute.
+    
+    This is a marker interface giving permission for an `IConfigurations`
+    adapter to store data in an attribute named `__configurations__`.
+
+    """
+
+
+AnnotationKey = 'zope.generic.configuration.IConfigurations'
+
+class IAnnotationsConfigurable(IConfigurable):
+    """Marker indicating that configurations can be stored on annotations.
+
+    """
+
+
+class IConfigurationModificationDescription(IModificationDescription):
+    """Declares the modified configuration by its interface and
+    the corresponding data that got modified.
+
+    An empty data dictionary implies that the configuration was deleted."""
+
+    interface = Attribute("The involved configuratoin interface.")
+    data = Attribute("A dict of modified configuration data.")
+
+
+
+class IObjectConfiguredEvent(IObjectEvent):
+    """An object's configurations has been modified.
+    
+    The corresponding modifications will be attached on the description attribute
+    """
+
+    descriptions = Attribute("Sequence of modifiaction descriptions.")
+
+    def items():
+        """List affected configuration interfaces and corresponding data from the descriptions."""
+
+    def get(interface, default=None):
+        """Return affected configuration data from the description or default."""


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

Added: zope.generic/trunk/src/zope/generic/configuration/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/testing.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/testing.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -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.component import provideAdapter
+from zope.configuration.xmlconfig import XMLConfig
+from zope.interface import Interface
+from zope.schema import TextLine
+
+import zope.generic.configuration.testing
+import zope.generic.keyface.testing
+import zope.generic.directlyprovides.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 attribute configurations adapter
+    import zope.generic.configuration.adapter
+    from zope.generic.configuration import IConfigurations
+    provideAdapter(zope.generic.configuration.adapter.AttributeConfigurations,
+        provides=IConfigurations)
+
+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)
+        # internal setup
+        setUp(doctest)
+
+    def tearDown(self, doctest=None):
+        super(PlacelessSetup, self).tearDown()
+        # external teardown
+        zope.generic.configuration.testing.tearDown(doctest)
+        zope.generic.keyface.testing.tearDown(doctest)
+        zope.generic.directlyprovides.testing.tearDown(doctest)
+        zope.generic.testing.testing.tearDown(doctest)
+        # internal teardown
+        tearDown(doctest)
+
+placelesssetup = PlacelessSetup()


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

Added: zope.generic/trunk/src/zope/generic/configuration/tests.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/tests.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/tests.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -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$
+"""
+
+import unittest
+
+from zope import component
+from zope import interface
+from zope.testing import doctest
+
+
+from zope.generic.testing.testing import InterfaceBaseTest
+from zope.generic.testing.testing import registerDirective
+
+from zope.generic.configuration import api
+from zope.generic.configuration import testing
+
+
+###############################################################################
+#
+# Unit tests  
+#
+###############################################################################
+
+class ConfigurationDataTest(InterfaceBaseTest):
+
+    _verify_class = False
+    _test_interface = testing.IFooConfiguration
+    _test_pos = (testing.IFooConfiguration, {'foo': u'Bla bla'})
+
+    @property
+    def _test_class(self):
+        from zope.generic.configuration.base import ConfigurationData
+        return  ConfigurationData
+
+    def test_readonly_attributes(self):
+        interface = self._test_interface
+        test_obj = self.makeTestObject()
+        for name in interface:
+            field = interface[name]
+            if field.readonly is True:
+                self.assertRaises(ValueError, setattr, test_obj, name, object())
+
+    def test_default_value(self):
+        interface = self._test_interface
+        test_obj = self.makeTestObject()
+        fo_field = interface['fo']
+        self.assertEqual(getattr(test_obj, 'fo'), fo_field.default)
+
+
+
+def test_suite():
+    return unittest.TestSuite((
+        unittest.makeSuite(ConfigurationDataTest),
+        doctest.DocTestSuite('zope.generic.configuration.helper'),
+        doctest.DocTestSuite('zope.generic.configuration.base'),
+        doctest.DocTestSuite('zope.generic.configuration.event'),
+        doctest.DocTestSuite('zope.generic.configuration.adapter'),
+        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/configuration/tests.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/configuration/zope.generic.component-configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/zope.generic.component-configure.zcml	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/zope.generic.component-configure.zcml	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+  <include package="zope.generic.configuration" />
+
+</configure>


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

Added: zope.generic/trunk/src/zope/generic/configuration/zope.generic.configuration-configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/zope.generic.configuration-configure.zcml	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/configuration/zope.generic.configuration-configure.zcml	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+  <include package="zope.generic.configuration" />
+
+</configure>


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

Modified: zope.generic/trunk/src/zope/generic/directlyprovides/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/directlyprovides/DEPENDENCIES.cfg	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/directlyprovides/DEPENDENCIES.cfg	2006-04-20 14:07:58 UTC (rev 67173)
@@ -1,8 +1,8 @@
-zope.generic.testing
 zope.app.event
 zope.app.testing
 zope.component
 zope.event
+zope.generic.testing
 zope.interface
 zope.schema
-zope.testing
+zope.testing
\ No newline at end of file

Added: zope.generic/trunk/src/zope/generic/informationprovider/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/DEPENDENCIES.cfg	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/DEPENDENCIES.cfg	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,11 @@
+zope.app.annotation
+zope.app.component
+zope.app.testing
+zope.component
+zope.configuration
+zope.generic.configuration
+zope.generic.directlyprovides
+zope.generic.keyface
+zope.generic.testing
+zope.interface
+zope.testing
\ No newline at end of file


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

Copied: zope.generic/trunk/src/zope/generic/informationprovider/NEW_README.txt (from rev 67168, zope.generic/trunk/src/zope/generic/component/NEW_README.txt)
===================================================================
--- zope.generic/trunk/src/zope/generic/component/NEW_README.txt	2006-04-20 08:32:31 UTC (rev 67168)
+++ zope.generic/trunk/src/zope/generic/informationprovider/NEW_README.txt	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,141 @@
+===================================
+How to use the information package?
+===================================
+
+We are developing a logger framework that can be used by user-application
+domains and supplier-application domains.
+
+Therefore we provide two public information registries for the members of our
+orthagonal application domain such as suppliers. The log-supplier-information 
+registry is holding supplier-specific informations. The log-user-information 
+registry is holding user-specific informations.
+
+In order to implement such an information registry we have to declare an
+*key-like* interface extending the IInformation interface:
+
+    >>> class ILogSupplierInformation(api.IInformationProvider):
+    ...     """Store log supplier information."""
+
+    >>> class ILogUserInformation(api.IInformationProvider):
+    ...     """Store log user information."""
+
+This specialized information interface has to be registered later by 
+informationRegistry-directive.
+
+Such an extended information is logical container for configurations and
+annotations. In our framework example we have now to specify concrete
+configuration that are registered to the two registries by the corresponding
+member group.
+
+A supplier has to provide global log instance (dotted name) and an optional
+time formatter. We capture this configuration information within a configuration
+that can be attached to a dedicated supplier information.
+
+    >>> from zope.interface import Interface
+    >>> from zope.configuration.fields import GlobalObject
+    >>> from zope.schema import BytesLine
+
+    >>> class ILogConfiguration(Interface):
+    ...     """Define the log output."""
+    ...     log = GlobalObject(title=u'Log')
+    ...     timeFormat = BytesLine(title=u'Time Format', required=False, default='%d.%m.%y')
+
+This configuration should be registered by using the configuration directive:
+
+    >>> registerDirective('''
+    ... <generic:keyface
+    ...     keyface="example.ILogConfiguration"
+    ...     type="zope.generic.configuration.IConfigurationType"
+    ...     />
+    ... ''') 
+
+A user has to provide logger configuration. This configuration defines the
+selected logger and a user-specific source tag:
+
+    >>> from zope.configuration.fields import GlobalInterface
+
+    >>> class ILoggerConfiguration(Interface):
+    ...     """Define the log output."""
+    ...     logger = GlobalInterface(title=u'Logger')
+    ...     sourceTag = BytesLine(title=u'Source Tag', required=False, default='     ')   
+
+    >>> registerDirective('''
+    ... <generic:keyface
+    ...     keyface="example.ILoggerConfiguration"
+    ...     type="zope.generic.configuration.IConfigurationType"
+    ...     />
+    ... ''') 
+
+TODO: Should be a dependency between informationRegistry and its configuration?
+
+    >>> registerDirective('''
+    ... <generic:informationProvider
+    ...     keyface='example.ILogSupplierInformation'
+    ...     registry='zope.generic.informationprovider.IInformationProviderInformation'
+    ...     />
+    ... ''')
+
+    >>> registerDirective('''
+    ... <generic:informationProvider
+    ...     keyface='example.ILogUserInformation'
+    ...     registry='zope.generic.informationprovider.IInformationProviderInformation'
+    ...     />
+    ... ''')
+
+The third part of our framework is the logger itself. The logger will be
+implmented as an adapter. We have to declare the logger interface:
+
+    >>> class ILogger(Interface):
+    ...     """Log."""
+    ...     def log(message):
+    ...         """Log the message."""
+
+    >>> from zope.interface import implements
+    >>> from zope.component import adapts
+    >>> from zope.generic.keyface import IKeyface
+
+    >>> class Logger(object):
+    ...     """Generic logger adapter."""
+    ...     implements(ILogger)
+    ...     adapts(IKeyface)
+    ...     def __init__(self, context):
+    ...         self.context = context
+    ...     def log(self, message):
+    ...         id = IKeyface(self.context())
+    ...         info = queryInformationProvider(id.keyface, ILogUserInformation)
+    >>> class Logger(object):
+    ...     """Generic logger adapter."""
+    ...     implements(ILogger)
+    ...     adapts(IKeyface)
+    ...     def __init__(self, context):
+    ...         self.context = context
+    ...     def log(self, message):
+    ...         id = IKeyface(self.context())
+    ...         info = queryInformationProvider(id.keyface, ILogUserInformation)
+    >>> class Logger(object):
+    ...     """Generic logger adapter."""
+    ...     implements(ILogger)
+    ...     adapts(IKeyface)
+    ...     def __init__(self, context):
+    ...         self.context = context
+    ...     def log(self, message):
+    ...         id = IKeyface(self.context())
+    ...         info = queryInformationProvider(id.keyface, ILogUserInformation)
+
+
+
+After the registration we can retrieve the registries using the
+queryInformationProvider function:
+    
+    >>> supplier_registry =  api.queryInformationProvider(ILogSupplierInformation)
+    >>> supplier_registry.label
+    u'ILogSupplierInformation'
+    >>> supplier_registry.hint
+    u'Store log supplier information.'
+
+    >>> user_registry =  api.queryInformationProvider(ILogUserInformation)
+    >>> user_registry.label
+    u'ILogUserInformation'
+    >>> user_registry.hint
+    u'Store log user information.'
+

Added: zope.generic/trunk/src/zope/generic/informationprovider/PUBLICATION.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/PUBLICATION.cfg	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/PUBLICATION.cfg	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,11 @@
+Metadata-Version: 1.0
+Name: zope.generic.informationprovider
+Summary: Provide generic information providers
+Author: Dominik Huber, Perse Engineering GmbH, Switzerland
+Author-email: dominik.huber at perse.ch
+License: ZPL 2.1
+Description:
+        You can register information providers to dedicated key interfaces.
+        Afterwards you can extend those information provider by informations
+        such as annotation or configurations. There are an api to handle
+        those informations uniquely. 


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

Added: zope.generic/trunk/src/zope/generic/informationprovider/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/README.txt	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/README.txt	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,377 @@
+=================
+Generic Component
+=================
+
+The key interface (see zope.generic.keyface) can be used to lookup corresponding
+information providers. This package offers a way to implement information
+providers generically.
+
+You can register different information providers to the same key interface. An
+information provider encapsulates a certain information aspect of the key 
+interface. The relation between information providers of a key interface to
+components providing the same key interface is similar to the object class 
+relation except that each informatio aspect follows its own information 
+acquisition.
+
+You can attache generic informations such as annotations or configurations
+to an certain information provider.
+
+The annotations mechanism is well-known and documented (zope.annotations).
+
+The configurations mechansim works similar to the annotations mechansim, but 
+references a single configuration (annotation) by its corresponding 
+configuration schema (regular interfac-based schema see zope.schema). 
+Such a configuration associates data and its corresponding schema. That means
+the configuration data provides the related schema and you can allways lookup
+dedicated configuration data by its configuration schema.
+
+Similar atomic informations defined by an annotation key or a 
+configuration schemas can be reused by different information providers. So
+the identical information types will receive a contextual meaning that is related
+to information provider type.
+
+Information Provider
+--------------------
+
+You can use the information provider directive to register an information 
+provider as utiliy with an interface extending IInformationProvider and a
+dotted name of an corresponding key interface as utility name:
+
+    >>> from zope.generic.informationprovider.api import IInformationProvider
+
+    >>> class ISpecialInformation(IInformationProvider):
+    ...    pass
+
+    >>> from zope.interface import Interface
+    >>> class IFooMarker(Interface):
+    ...    pass
+
+    >>> registerDirective('''
+    ... <generic:informationProvider
+    ...     keyface="example.IFooMarker"
+    ...     registry="example.ISpecialInformation"
+    ...     label='Foo Specials' hint='Bla bla foo.'
+    ...     />
+    ... ''')
+
+After a registration the information provider can be looked up.
+All information provider with the same interface can be gotten by the 
+getInformationProvidersFor function:
+
+    >>> listing = list(api.getInformationProvidersFor(ISpecialInformation))
+    >>> len(listing) is 1
+    True
+    >>> [(key.__name__, value) for key, value in listing]
+    [('IFooMarker', <zope.generic.informationprovider.base.InformationProvider ...>)]
+
+A single information provider can be retrieved by the get- or 
+queryInformationProvider function:
+
+    >>> info = api.getInformationProvider(IFooMarker, ISpecialInformation)
+    >>> info = api.queryInformationProvider(IFooMarker, ISpecialInformation)
+
+    >>> listing[0][1] == info
+    True
+    >>> listing[0][0] == IFooMarker
+    True
+
+    >>> info.keyface == IFooMarker
+    True
+    >>> ISpecialInformation.providedBy(info)
+    True
+    >>> info.label = u'Foo Specials'
+    >>> info.hint = u'Bla bla foo.'
+
+If no information provider is available for a certain interface the default
+value is returned. If no default is defined None is returned:
+
+    >>> class IBarMarker(Interface):
+    ...    pass
+
+    >>> default = object()
+    >>> info = api.queryInformationProvider(IBarMarker, ISpecialInformation, default)
+    >>> info is default
+    True
+
+    >>> info = api.queryInformationProvider(IBarMarker, ISpecialInformation)
+    >>> info is None
+    True
+
+Information providers are annotable
+-----------------------------------
+
+Information providers are annotable. The annotations mechanism is used to provide
+additional informations in a generic manner:
+
+    >>> from zope.app.annotation.interfaces import IAnnotations
+
+    >>> info = api.queryInformationProvider(IFooMarker, ISpecialInformation)
+
+    >>> annotations = IAnnotations(info)
+    >>> annotations.get('test.annotation')
+    >>> annotations['test.annotation']
+    Traceback (most recent call last):
+    ...
+    KeyError: 'test.annotation'
+    >>> list(annotations.keys())
+    []
+    >>> del annotations['test.annotation']
+    Traceback (most recent call last):
+    ...
+    KeyError: 'test.annotation'
+    >>> annotations['test.annotation'] = 'a'
+    >>> annotations.get('test.annotation')
+    'a'
+    >>> annotations['test.annotation']
+    'a'
+    >>> list(annotations.keys())
+    ['test.annotation']
+    >>> del annotations['test.annotation']
+
+
+Information providers are configurable
+--------------------------------------
+
+Information providers are configurable. The configurations mechanism is used 
+to provide additional configurations in a generic manner. A configuration
+is declared by a configuration schema providing IConfigurationType:
+
+    >>> from zope.schema import TextLine
+        
+    >>> class IMyConfiguration(interface.Interface):
+    ...     my = TextLine(title=u'My')
+
+    >>> registerDirective('''
+    ... <generic:keyface
+    ...     keyface="example.IMyConfiguration"
+    ...     type="zope.generic.configuration.IConfigurationType"
+    ...     />
+    ... ''') 
+
+    >>> from zope.generic.configuration.api import IConfigurationType
+
+    >>> IConfigurationType.providedBy(IMyConfiguration)
+    True
+
+We now can use this configuration to extend our information provider of the
+key interface IFooMarker. At the moment there are no configurations:
+
+    >>> api.queryInformation(info, IMyConfiguration) is None
+    True
+
+The configuration subdirective of the information provider directive provides a mechanism
+to register further configurations to an information provider:
+
+    >>> from zope.generic.configuration.api import ConfigurationData
+    >>> my_information_config = ConfigurationData(IMyConfiguration, {'my': u'My!'})
+
+    >>> registerDirective('''
+    ... <generic:informationProvider
+    ...     keyface="example.IFooMarker"
+    ...     registry="example.ISpecialInformation"
+    ...     label='Foo Specials' hint='Bla bla foo.'
+    ...     >
+    ...        <configuration
+    ...            keyface="example.IMyConfiguration"
+    ...            data="example.my_information_config"
+    ...            />
+    ...     </generic:informationProvider>
+    ... ''')
+
+    >>> info = api.queryInformationProvider(IFooMarker, ISpecialInformation)
+    >>> api.queryInformation(info, IMyConfiguration) is my_information_config
+    True
+
+
+Configurations
+---------------
+
+Configurations is a container of configuration data. Configuration data are
+defined by an schema which is providing IConfigurationType. The configuration
+data itself has to provide the schema that is used to reference it.
+
+    >>> from zope.schema import TextLine
+        
+    >>> class IMyConfiguration(interface.Interface):
+    ...     my = TextLine(title=u'My')
+
+    >>> registerDirective('''
+    ... <generic:keyface
+    ...     keyface="example.IMyConfiguration"
+    ...     type="zope.generic.configuration.IConfigurationType"
+    ...     />
+    ... ''') 
+
+    >>> from zope.generic.configuration.api import IConfigurationType
+    >>> IConfigurationType.providedBy(IMyConfiguration)
+    True
+ 
+Regularly local configurations are provided by objects marked with
+IAttributeConfigurations automatically:
+
+    >>> from zope.interface import implements
+    >>> from zope.generic.configuration.api import IAttributeConfigurable
+
+    >>> class Foo(object):
+    ...    implements(IAttributeConfigurable)
+
+    >>> foo = Foo()
+    >>> IAttributeConfigurable.providedBy(foo)
+    True
+
+Now you can adapt you to IConfigurations:
+
+    >>> from zope.generic.configuration.api import IConfigurations
+
+    >>> configurations = IConfigurations(foo)
+    >>> IConfigurations.providedBy(configurations)
+    True
+
+At the beginning the IConfigurations storage does not exists:
+
+    >>> configurations.__nonzero__()
+    False
+
+Configuration data will be stored under an key interface within the
+configurations. Such a configuration schema defines its configuration
+data:
+
+    >>> from zope.interface import Interface
+    >>> from zope.schema import TextLine
+    
+    >>> class IFooConfiguration(Interface):
+    ...    foo = TextLine(title=u'Foo')
+    ...    optional = TextLine(title=u'Optional', required=False, default=u'Bla')
+
+The configuration schema is a regular schema, but it has to be typed
+by IConfigurationType (Regularly done by the configuration directive):
+
+    >>> from zope.interface import directlyProvides
+
+    >>> directlyProvides(IFooConfiguration, IConfigurationType)
+    >>> IConfigurationType.providedBy(IFooConfiguration)
+    True
+
+The configurations provides a regular dictionary api by the UserDictMixin
+(like AttributeAnnotations). This mixin bases on the following methods:
+
+    >>> configurations[IFooConfiguration]
+    Traceback (most recent call last):
+    ...
+    KeyError: <InterfaceClass example.IFooConfiguration>
+
+    >>> del configurations[IFooConfiguration]
+    Traceback (most recent call last):
+    ...
+    KeyError: <InterfaceClass example.IFooConfiguration>
+
+    >>> configurations.keys()
+    []
+
+... if a value might be set to the configurations it must provide the 
+configuration schema itself. This key interface must provide IConfigurationType:
+
+    >>> class IBarConfiguration(Interface):
+    ...    bar = TextLine(title=u'Bar')
+
+    >>> configurations[IBarConfiguration] = object()
+    Traceback (most recent call last):
+    ...
+    KeyError: 'Interface key IBarConfiguration does not provide IConfigurationType.'
+
+    >>> configurations[IFooConfiguration] = object()
+    Traceback (most recent call last):
+    ...
+    ValueError: Value does not provide IFooConfiguration.
+
+Furthermore there is an update method that can be used to update a specific
+configuration. This method can be only used if a configuration already exists:
+
+    >>> configurations.update(IFooConfiguration, {'foo': u'Foo!'})
+    Traceback (most recent call last):
+    ...
+    KeyError: <InterfaceClass example.IFooConfiguration>
+
+You can create valid configuration data using the generic ConfigurationData
+implementation and a configuration schema:
+
+    >>> from zope.generic.configuration.api import ConfigurationData
+
+    >>> data = ConfigurationData(IFooConfiguration, {'foo': u'Foo!'})
+
+    >>> configurations[IFooConfiguration] = data
+
+The setting of the configuration is notified by a object configured event if 
+the parent has a location an the parent's parent is not None:
+
+    >>> from zope.app.event.tests.placelesssetup import getEvents, clearEvents
+    >>> from zope.generic.configuration.api import IObjectConfiguredEvent
+
+    >>> events = getEvents()
+    >>> len(events)
+    0
+
+    >>> from zope.app.location import Location
+    >>> parent = Location()
+    >>> configurations.__parent__ = parent
+    
+    >>> configurations[IFooConfiguration] = data
+    >>> events = getEvents()
+    >>> len(events)
+    0
+
+    >>> parent.__parent__ = Location()
+    >>> configurations[IFooConfiguration] = data
+    >>> events = getEvents()
+    >>> len(events)
+    1
+
+    >>> event = events.pop()
+    >>> IObjectConfiguredEvent.providedBy(event)
+    True
+    >>> [(key.__name__, value) for key, value in event.items()]
+    [('IFooConfiguration', {'foo': u'Foo!', 'optional': u'Bla'})]
+
+If the configuration data is set the first time an oobtree storage is set
+to the __configurations__ attribute of the context:
+
+    >>> configurations.__nonzero__()
+    True
+
+    >>> IFooConfiguration in configurations
+    True
+
+    >>> configurations[IFooConfiguration] == data
+    True
+
+    >>> [iface.__name__ for iface in configurations.keys()]
+    ['IFooConfiguration']
+
+You should update a configuration using the update method instead of setting
+new configuration data. If the change differs from the configuration an object
+configuration modified event is notify else not:
+
+    >>> clearEvents()
+    >>> configurations.update(IFooConfiguration, {'foo': u'Bar!'})
+    >>> events = getEvents()
+    >>> len(events)
+    1
+    >>> event = events.pop()
+    >>> [(key.__name__, value) for key, value in event.items()]
+    [('IFooConfiguration', {'foo': u'Bar!'})]
+
+Also the deletion is notified by an empty dict:
+
+    >>> clearEvents()
+
+    >>> del configurations[IFooConfiguration]
+    >>> IFooConfiguration in configurations
+    False
+
+    >>> events = getEvents()
+    >>> len(events)
+    1
+    >>> event = events.pop()
+    >>> [(key.__name__, value) for key, value in event.items()]
+    [('IFooConfiguration', {})]
+


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

Added: zope.generic/trunk/src/zope/generic/informationprovider/SETUP.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/SETUP.cfg	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/SETUP.cfg	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,3 @@
+<data-files zopeskel/etc/package-includes>
+  zope.generic.informationprovider-*.zcml
+</data-files>
\ No newline at end of file


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

Added: zope.generic/trunk/src/zope/generic/informationprovider/__init__.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/__init__.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/__init__.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -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.informationprovider.interfaces import *


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

Added: zope.generic/trunk/src/zope/generic/informationprovider/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/api.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/api.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,104 @@
+##############################################################################
+#
+# 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.annotation import IAnnotations
+from zope.component import getUtilitiesFor
+from zope.component import getUtility
+from zope.generic.keyface.api import getKey
+from zope.generic.keyface.api import queryKey
+from zope.generic.keyface.api import toDottedName
+from zope.generic.keyface.api import toKeyface
+
+from zope.generic.configuration import IConfigurations
+from zope.generic.configuration import IConfigurationType
+from zope.generic.configuration.api import ConfigurationData
+
+from zope.generic.informationprovider import *
+from zope.generic.informationprovider.base import InformationProvider
+
+
+
+def getInformationProvider(object, provider=IInformationProviderInformation):
+    """Evaluate an information provider for an object."""
+
+    return getUtility(provider, toDottedName(getKey(object)))
+
+
+
+def queryInformationProvider(object, provider=IInformationProviderInformation, default=None):
+    """Evalute an information provider or return default."""
+    try:
+        return getInformationProvider(object, provider)
+
+    except:
+        return default
+
+
+
+def getInformationProvidersFor(provider, default=None):
+    """Evaluate all information providers of a certain information aspect."""
+
+    for name, information in getUtilitiesFor(provider):
+        yield (toKeyface(name), information)
+
+
+
+def getInformation(context, keyface):
+    """Evaluate an information by a keyface (string or key keyface)."""
+    if IConfigurationType.providedBy(keyface):
+        return keyface(IConfigurations(context))
+
+    else:
+        return IAnnotations(context)[keyface]
+
+
+
+def queryInformation(context, keyface, default=None):
+    """Evaluate an information by a keyface (string or key interface)."""
+    try:
+        return getInformation(context, keyface)
+
+    except:
+        return default
+
+
+
+def provideInformation(context, keyface, information):
+    """Set an information to a context using a keyface (string or key interface)."""
+
+    if IConfigurationType.providedBy(keyface):
+        if type(information) is dict:
+            information = ConfigurationData(keyface, information)
+    
+        IConfigurations(context)[keyface] = information
+
+    else:
+        IAnnotations(context)[keyface] = information
+
+
+
+def deleteInformation(context, keyface):
+    """Delete an information of a context using a keyface (string or key interface)."""
+
+    if IConfigurationType.providedBy(keyface):
+        del IConfigurations(context)[keyface]
+    
+    else:
+        del IAnnotations(context)[keyface]


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

Added: zope.generic/trunk/src/zope/generic/informationprovider/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/base.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/base.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,79 @@
+##############################################################################
+#
+# 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.annotation.interfaces import IAttributeAnnotatable
+from zope.app.i18n import ZopeMessageFactory as _
+from zope.interface import alsoProvides
+from zope.interface import implements
+
+from zope.generic.configuration import IAttributeConfigurable
+from zope.generic.keyface.api import KeyfaceDescription
+
+from zope.generic.informationprovider import IInformationProvider
+
+
+
+class InformationProvider(KeyfaceDescription):
+    """Generic information provider.
+
+    Information do relate a dedicated type of information marked as an interface
+    extending IInformationProvider and another marker interface:
+
+        >>> class ISpecialInformation(IInformationProvider):
+        ...    pass
+
+        >>> from zope.interface import Interface
+        >>> class IFooMarker(Interface):
+        ...    '''Foo is member of the example domain.'''
+
+        >>> info = InformationProvider(IFooMarker, ISpecialInformation)
+
+    The information will provide the interface of the dedicated information:
+
+        >>> ISpecialInformation.providedBy(info)
+        True
+
+    The information is related to the interface declared by the interface
+    attribute:
+
+        >>> info.keyface == IFooMarker
+        True
+        >>> info.label
+        u'IFooMarker'
+        
+        >>> info.hint
+        u'Foo is member of the example domain.'
+
+
+    Often you will provide a specific label and hint for the end-user:
+
+        >>> info = InformationProvider(IFooMarker, ISpecialInformation, u'Foo', u'Bla bla.')
+        >>> info.label
+        u'Foo'
+        
+        >>> info.hint
+        u'Bla bla.'
+    """
+
+    implements(IInformationProvider, IAttributeConfigurable, IAttributeAnnotatable)
+
+    def __init__(self, keyface, provides, label=None, hint=None):
+        super(InformationProvider, self).__init__(keyface, label, hint)
+        alsoProvides(self, provides)
\ No newline at end of file


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

Added: zope.generic/trunk/src/zope/generic/informationprovider/configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/configure.zcml	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/configure.zcml	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,12 @@
+<configure
+  xmlns="http://namespaces.zope.org/zope"
+  xmlns:generic="http://namespaces.zope.org/generic"
+  i18n_domain="zope">
+ 
+  <generic:informationProvider
+      keyface=".IInformationProviderInformation"
+      label="Information Provider Information"
+      registry=".IInformationProviderInformation"
+      />
+
+</configure>


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

Added: zope.generic/trunk/src/zope/generic/informationprovider/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/interfaces.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/interfaces.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -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$
+"""
+
+__docformat__ = 'restructuredtext'
+
+from zope.app.i18n import ZopeMessageFactory as _
+from zope.interface import alsoProvides
+
+from zope.generic.keyface import IKeyfaceType
+from zope.generic.keyface import IKeyfaceDescription
+
+
+
+###############################################################################
+#
+# base configurations related interfaces 
+#
+###############################################################################
+
+
+class IInformationProviderType(IKeyfaceType):
+    """Mark information interface as information type."""
+
+
+
+class IInformationProvider(IKeyfaceDescription):
+    """Provide information about a dedicated key interfaces.
+    
+    A configuration related to the key interface can be stored within the
+    provider's configurations.
+    
+    Dedicated information providers has to extend this interface.
+    """
+
+
+
+class IInformationProviderInformation(IInformationProvider):
+    """Provide information about information providers."""
+
+
+
+alsoProvides(IInformationProviderInformation, IInformationProviderType)
+


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

Added: zope.generic/trunk/src/zope/generic/informationprovider/meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/meta.zcml	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/meta.zcml	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,22 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:meta="http://namespaces.zope.org/meta">
+
+  <meta:directives namespace="http://namespaces.zope.org/generic">
+
+    <meta:complexDirective
+        name="informationProvider"
+        schema=".metadirectives.IInformationProviderDirective"
+        handler=".metaconfigure.InformationProviderDirective"
+        >
+
+      <meta:subdirective
+          name="configuration"
+          schema=".metadirectives.IConfigurationSubdirective"
+          />
+
+    </meta:complexDirective>
+
+  </meta:directives>
+
+</configure>


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

Copied: zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py (from rev 67079, zope.generic/trunk/src/zope/generic/component/metaconfigure.py)
===================================================================
--- zope.generic/trunk/src/zope/generic/component/metaconfigure.py	2006-04-18 16:22:46 UTC (rev 67079)
+++ zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,136 @@
+##############################################################################
+#
+# Copyright (c) 2005, 2006 Projekt01 GmbH 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.interface import provideInterface
+from zope.component import provideUtility
+from zope.configuration.exceptions import ConfigurationError
+from zope.interface import alsoProvides
+
+from zope.generic.configuration import IConfigurations
+from zope.generic.configuration.api import ConfigurationData
+from zope.generic.keyface.api import toDottedName
+
+from zope.generic.informationprovider.base import InformationProvider
+from zope.generic.informationprovider import IInformationProvider
+from zope.generic.informationprovider import IInformationProviderInformation
+from zope.generic.informationprovider import IInformationProviderType
+from zope.generic.informationprovider.api import queryInformationProvider
+
+
+
+def provideInformationProvider(keyface, registry=IInformationProviderInformation, label=None, hint=None, factory=None):
+    """Provide new information for the given registry-interface.
+
+    Register an information as utiliy under registry-interface using
+    the dotted name of the interface as utility name:
+
+        >>> class ISpecialInformation(IInformationProvider):
+        ...    pass
+
+        >>> from zope.interface import Interface
+        >>> class IFooMarker(Interface):
+        ...    pass
+
+        >>> provideInformationProvider(IFooMarker, ISpecialInformation)
+
+    The information can be queried using the following method:
+
+        >>> from zope.generic.configuration.helper import queryInformationProvider
+        >>> info = queryInformationProvider(IFooMarker, ISpecialInformation)
+        >>> info.keyface == IFooMarker
+        True
+        >>> ISpecialInformation.providedBy(info)
+        True
+
+    """
+
+    # precondition
+    if not registry.extends(IInformationProvider):
+        raise ValueError('Registry must extend %s.' % IInformationProvider.__name__)
+
+    if factory is None:
+        factory = InformationProvider
+    
+    component = factory(keyface, registry, label, hint)
+
+    if not registry.providedBy(component):
+        raise ValueError('Factory must implement %s.' % registry.__name__)
+    
+    provideUtility(component, provides=registry, name=toDottedName(keyface))
+
+
+
+def provideConfiguration(keyface, registry, configuration, data):
+    """Provide configuration for a certain type marker."""
+
+    info = queryInformationProvider(keyface, registry)
+    
+    configurations = IConfigurations(info)
+    configurations[configuration] = data
+
+
+
+class InformationProviderDirective(object):
+    """Provide a new information of a certain information registry."""
+    
+    _information_type = None
+
+    def __init__(self, _context, keyface, registry, label=None, hint=None):
+        self._keyface = keyface
+        self._context = _context
+        self._registry = registry
+    
+        # assert type as soon as possible
+        if self._information_type is not None:
+            alsoProvides(keyface, self._information_type)
+    
+        _context.action(
+            discriminator = ('provideInformationProvider', self._keyface, self._registry),
+            callable = provideInformationProvider,
+            args = (self._keyface, self._registry, label, hint),
+            )
+    
+        _context.action(
+            discriminator = None,
+            callable = provideInterface,
+            args = (None, self._keyface),
+            )
+    
+        _context.action(
+            discriminator = None,
+            callable = provideInterface,
+            args = (None, self._registry),
+            )
+
+    def __call__(self):
+        "Handle empty/simple declaration."
+        return ()
+
+    def configuration(self, _context, keyface, data):
+        # preconditions
+        if not keyface.providedBy(data):
+            raise ConfigurationError('Data attribute must provide %s.' % keyface.__name__)
+
+        _context.action(
+            discriminator = (
+            'InformationConfiguration', self._keyface, self._registry, keyface),
+            callable = provideConfiguration,
+            args = (self._keyface, self._registry, keyface, data),
+            )

Copied: zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py (from rev 67079, zope.generic/trunk/src/zope/generic/component/metadirectives.py)
===================================================================
--- zope.generic/trunk/src/zope/generic/component/metadirectives.py	2006-04-18 16:22:46 UTC (rev 67079)
+++ zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,82 @@
+##############################################################################
+#
+# 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.configuration.fields import GlobalInterface
+from zope.configuration.fields import GlobalObject
+from zope.configuration.fields import MessageID
+from zope.interface import Interface
+
+from zope.generic.informationprovider import IInformationProvider
+
+
+
+class IBaseInformationProviderDirective(Interface):
+    """Base information attributes."""
+
+    keyface = GlobalInterface(
+        title=_('Interface'),
+        description=_('Interface that represents an information.'),
+        required=True
+        )
+
+    label = MessageID(
+        title=_('Label'),
+        description=_('Label of the information.'),
+        required=False
+        )
+
+    hint = MessageID(
+        title=_('Hint'),
+        description=_('Hint of the informtion.'),
+        required=False
+        )
+
+
+
+class IInformationProviderDirective(IBaseInformationProviderDirective):
+    """Directive to register an information to corresponding information
+    registry."""
+
+    registry = GlobalInterface(
+        title=_('Information Registry Key'),
+        description=_('A registry key is a dedicated interface which should extend' +
+                      'IInformationProvider.'),
+        required=True,
+        constraint=lambda v: v.extends(IInformationProvider)
+        )
+
+
+
+class IConfigurationSubdirective(Interface):
+    """Declare a certain configuration of a type."""
+
+    keyface = GlobalInterface(
+        title=_('Interface'),
+        description=_('Interface referencing a configuraiton.'),
+        required=True
+        )
+
+    data = GlobalObject(
+        title=_('Data'),
+        description=_('Configuration data component providing the configuraiton interface.'),
+        required=True
+        )
+

Added: zope.generic/trunk/src/zope/generic/informationprovider/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/testing.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/testing.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,79 @@
+##############################################################################
+#
+# 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
+
+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
+
+################################################################################
+#
+# Public Test implementations
+#
+################################################################################
+
+
+
+################################################################################
+#
+# Placeless setup
+#
+################################################################################
+
+# specific tests
+def setUp(doctest=None):
+    # register attribute configurations adapter
+
+    # register the directive of this package
+    import zope.generic.informationprovider
+    XMLConfig('meta.zcml', zope.generic.informationprovider)()
+
+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)
+        # internal setup
+        setUp(doctest)
+
+    def tearDown(self, doctest=None):
+        super(PlacelessSetup, self).tearDown()
+        # external teardown
+        zope.generic.configuration.testing.tearDown(doctest)
+        zope.generic.keyface.testing.tearDown(doctest)
+        zope.generic.directlyprovides.testing.tearDown(doctest)
+        zope.generic.testing.testing.tearDown(doctest)
+        # internal teardown
+        tearDown(doctest)
+
+placelesssetup = PlacelessSetup()


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

Added: zope.generic/trunk/src/zope/generic/informationprovider/tests.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/tests.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/tests.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,63 @@
+##############################################################################
+#
+# 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.informationprovider import api
+from zope.generic.informationprovider import testing
+
+
+###############################################################################
+#
+# Unit tests  
+#
+###############################################################################
+
+
+
+def test_suite():
+    return unittest.TestSuite((
+        doctest.DocTestSuite('zope.generic.informationprovider.base'),
+        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),
+
+        doctest.DocFileSuite('NEW_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/informationprovider/tests.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zope.generic/trunk/src/zope/generic/informationprovider/zope.generic.informationprovider-configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/zope.generic.informationprovider-configure.zcml	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/zope.generic.informationprovider-configure.zcml	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+  <include package="zope.generic.informationprovider" />
+
+</configure>


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

Added: zope.generic/trunk/src/zope/generic/informationprovider/zope.generic.informationprovider-meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/zope.generic.informationprovider-meta.zcml	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/informationprovider/zope.generic.informationprovider-meta.zcml	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+  <include package="zope.generic.informationprovider" file="meta.zcml" />
+
+</configure>


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

Modified: zope.generic/trunk/src/zope/generic/keyface/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/keyface/DEPENDENCIES.cfg	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/keyface/DEPENDENCIES.cfg	2006-04-20 14:07:58 UTC (rev 67173)
@@ -1,14 +1,9 @@
-BTrees
-persistent
-zope.app.annotation
 zope.app.component
-zope.app.event
 zope.app.location
 zope.app.testing
 zope.component
 zope.configuration
 zope.dottedname
-zope.event
 zope.generic.directlyprovides
 zope.generic.testing
 zope.interface

Added: zope.generic/trunk/src/zope/generic/keyface/PUBLICATION.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/keyface/PUBLICATION.cfg	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/keyface/PUBLICATION.cfg	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: zope.generic.keyface
+Summary: Provide a key interface to invoke corresponding components
+Author: Dominik Huber, Perse Engineering GmbH, Switzerland
+Author-email: dominik.huber at perse.ch
+License: ZPL 2.1
+Description:
+        The configurations mechansim works similar to the annotations mechansim,
+        but references a single configuration (annotation) by its corresponding 
+		configuration schema.


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

Modified: zope.generic/trunk/src/zope/generic/keyface/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/keyface/README.txt	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/keyface/README.txt	2006-04-20 14:07:58 UTC (rev 67173)
@@ -21,6 +21,21 @@
     >>> class IFooMarker(interface.Interface):
     ...    pass
 
+The key interface should be registered by the keyface directive. This asserts
+that those interface got marked as IKeyfaceType:
+
+    >>> api.IKeyfaceType.providedBy(IFooMarker)
+    False
+
+    >>> registerDirective('''
+    ... <generic:keyface
+    ...     keyface="example.IFooMarker"
+    ...     />
+    ... ''') 
+
+    >>> api.IKeyfaceType.providedBy(IFooMarker)
+    True
+
 Then we have to decorate a corresponding key-faced component:
 
     >>> class FooKeyfaced(object):
@@ -67,3 +82,33 @@
     True
 
 
+New key interface types can be created to provide key interfaces with a dedicated
+usage (for example IConfigurationType). Attention keyfaces can be typed only
+once by a type deriving from IKeyfaceType:
+
+    >>> class IMyKeyfaceType(api.IKeyfaceType):
+    ...    pass
+
+    >>> registerDirective('''
+    ... <generic:keyface
+    ...     keyface="example.IFooMarker"
+    ...     type="example.IMyKeyfaceType"
+    ...     />
+    ... ''') 
+    Traceback (most recent call last):
+    ...
+    ZopeXMLConfigurationError: ...ConfigurationError: Keyface IFooMarker already registered.
+
+    >>> class IBarMarker(interface.Interface):
+    ...    pass
+
+
+    >>> registerDirective('''
+    ... <generic:keyface
+    ...     keyface="example.IBarMarker"
+    ...     type="example.IMyKeyfaceType"
+    ...     />
+    ... ''') 
+
+    >>> api.IKeyfaceType.providedBy(IBarMarker)
+    True
\ No newline at end of file

Modified: zope.generic/trunk/src/zope/generic/keyface/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/keyface/api.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/keyface/api.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -22,6 +22,8 @@
 from zope.generic.keyface.adapter import KeyfaceForAttributeKeyfaced
 from zope.generic.keyface.base import Keyface
 from zope.generic.keyface.base import KeyfaceDescription
+from zope.generic.keyface.helper import toDottedName
+from zope.generic.keyface.helper import toKeyface
 
 
 

Added: zope.generic/trunk/src/zope/generic/keyface/helper.py
===================================================================
--- zope.generic/trunk/src/zope/generic/keyface/helper.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/keyface/helper.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,38 @@
+##############################################################################
+#
+# 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.dottedname.resolve import resolve
+
+
+
+def toDottedName(component):
+    if component is None:
+        return 'None'
+    return component.__module__ + '.' + component.__name__
+
+
+# cache
+__name_to_component = {}
+
+def toKeyface(name):
+    try:
+        return __name_to_component[name]
+    except KeyError:
+        return __name_to_component.setdefault(name, resolve(name))


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

Modified: zope.generic/trunk/src/zope/generic/keyface/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/keyface/interfaces.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/keyface/interfaces.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -53,6 +53,15 @@
 
 
 
+class IKeyfaceType(IInterface):
+    """Mark key interfaces.
+
+    You can derive from this type to provide dedicated keyface types. A key 
+    interface should only provide a single keyface type.
+    """
+
+
+
 class IKeyface(IKeyfaced):
     """Declare a key interface as component-specific key.
 
@@ -64,7 +73,7 @@
         description=_('Key interface of the adapted context.'),
         required=True,
         readonly=True,
-        schema=IInterface)
+        schema=IKeyfaceType)
 
 
 

Added: zope.generic/trunk/src/zope/generic/keyface/meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/keyface/meta.zcml	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/keyface/meta.zcml	2006-04-20 14:07:58 UTC (rev 67173)
@@ -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="keyface"
+        schema=".metadirectives.IKeyFaceDirective"
+        handler=".metaconfigure.keyfaceDirective"
+        />
+
+  </meta:directives>
+
+</configure>


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

Added: zope.generic/trunk/src/zope/generic/keyface/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/keyface/metaconfigure.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/keyface/metaconfigure.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,49 @@
+##############################################################################
+#
+# Copyright (c) 2005, 2006 Projekt01 GmbH 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.interface import provideInterface
+from zope.configuration.exceptions import ConfigurationError
+from zope.interface import alsoProvides
+
+from zope.generic.keyface import IKeyfaceType
+
+
+
+def keyfaceDirective(_context, keyface, type=None):
+    """Mark and register an new key interface."""
+
+    # preconditions: type only once
+    if IKeyfaceType.providedBy(keyface):
+        raise ConfigurationError('Keyface %s already registered.' % keyface.__name__)
+
+    if type is not None and not type.extends(IKeyfaceType):
+        raise ConfigurationError('Type %s should extend %s.' % (type.__name__, IKeyfaceType.__name__))
+
+    # assert type as soon as possible
+    if type is None:
+        type = IKeyfaceType
+    
+    alsoProvides(keyface, type)
+
+    _context.action(
+        discriminator = None,
+        callable = provideInterface,
+        args = (None, keyface, type),
+        )


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

Added: zope.generic/trunk/src/zope/generic/keyface/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/keyface/metadirectives.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/keyface/metadirectives.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,42 @@
+##############################################################################
+#
+# 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.configuration.fields import GlobalInterface
+from zope.interface import Interface
+
+
+
+class IKeyFaceDirective(Interface):
+    """Base information attributes."""
+
+    keyface = GlobalInterface(
+        title=_('Key Interface'),
+        description=_('Interface that represents an information key.'),
+        required=True
+        )
+
+    type = GlobalInterface(
+        title=_('Key Interface Type'),
+        description=_('Type a key interface by an interface derived from ' +
+                      'IKeyfaceType. If no type provided the interface will ' +
+                      'marked by IKeyfaceType.'),
+        required=False
+        )


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

Modified: zope.generic/trunk/src/zope/generic/keyface/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/keyface/testing.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/keyface/testing.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -56,6 +56,10 @@
     provideAdapter(zope.generic.keyface.adapter.KeyfaceForAttributeKeyfaced ,
         provides=IKeyface)
 
+    # register the directive of this package
+    import zope.generic.keyface
+    XMLConfig('meta.zcml', zope.generic.keyface)()
+
 def tearDown(doctest=None):
     pass
 

Added: zope.generic/trunk/src/zope/generic/keyface/zope.generic.keyface-meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/keyface/zope.generic.keyface-meta.zcml	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/keyface/zope.generic.keyface-meta.zcml	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+  <include package="zope.generic.keyface" file="meta.zcml" />
+
+</configure>


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

Added: zope.generic/trunk/src/zope/generic/operation/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/DEPENDENCIES.cfg	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/operation/DEPENDENCIES.cfg	2006-04-20 14:07:58 UTC (rev 67173)
@@ -0,0 +1,12 @@
+zope.app.component
+zope.app.testing
+zope.component
+zope.configuration
+zope.generic.configuration
+zope.generic.directlyprovides
+zope.generic.informationprovider
+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/operation/DEPENDENCIES.cfg
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: zope.generic/trunk/src/zope/generic/operation/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/README.txt	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/operation/README.txt	2006-04-20 14:07:58 UTC (rev 67173)
@@ -43,26 +43,30 @@
 
 
     >>> registerDirective('''
-    ... <generic:configuration
+    ... <generic:keyface
     ...     keyface="example.IPAUConfig"
+    ...     type="zope.generic.configuration.IConfigurationType"
     ...     />
     ... ''') 
 
     >>> registerDirective('''
-    ... <generic:configuration
+    ... <generic:keyface
     ...     keyface="example.IAnyInputConfig"
+    ...     type="zope.generic.configuration.IConfigurationType"
     ...     />
     ... ''') 
 
     >>> registerDirective('''
-    ... <generic:configuration
+    ... <generic:keyface
     ...     keyface="example.IAConfig"
+    ...     type="zope.generic.configuration.IConfigurationType"
     ...     />
     ... ''') 
 
     >>> registerDirective('''
-    ... <generic:configuration
+    ... <generic:keyface
     ...     keyface="example.IBConfig"
+    ...     type="zope.generic.configuration.IConfigurationType"
     ...     />
     ... ''') 
 
@@ -119,8 +123,9 @@
     ...    any_c = TextLine()
 
     >>> registerDirective('''
-    ... <generic:configuration
+    ... <generic:keyface
     ...     keyface="example.IComplexConfig"
+    ...     type="zope.generic.configuration.IConfigurationType"
     ...     />
     ... ''') 
 
@@ -147,7 +152,7 @@
 For each operation directive we registered an operation information. This
 operation information can be retrieved:
 
-    >>> from zope.generic.component.api import getInformationProvidersFor
+    >>> from zope.generic.informationprovider.api import getInformationProvidersFor
 
     >>> listing = list(getInformationProvidersFor(api.IOperationInformation))
     >>> len(listing)

Modified: zope.generic/trunk/src/zope/generic/operation/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/base.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/operation/base.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -22,7 +22,7 @@
 from zope.schema.fieldproperty import FieldProperty
 
 from zope.generic.keyface import IAttributeKeyfaced
-from zope.generic.component.api import Keyface
+from zope.generic.keyface.api import Keyface
 
 from zope.generic.operation import IOperation
 from zope.generic.operation import IPrivateOperation

Modified: zope.generic/trunk/src/zope/generic/operation/helper.py
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/helper.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/operation/helper.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -18,8 +18,8 @@
 
 __docformat__ = 'restructuredtext'
 
-from zope.generic.component.api import getInformationProvider
-from zope.generic.component.api import getInformation
+from zope.generic.informationprovider.api import getInformationProvider
+from zope.generic.informationprovider.api import getInformation
 
 from zope.generic.operation import IOperationInformation
 from zope.generic.operation import IOperationConfiguration

Modified: zope.generic/trunk/src/zope/generic/operation/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/interfaces.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/operation/interfaces.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -21,20 +21,18 @@
 from zope.app.i18n import ZopeMessageFactory as _
 from zope.interface import alsoProvides
 from zope.interface import Interface
-from zope.interface.interfaces import IInterface
 from zope.schema import Bool
 from zope.schema import Object
 from zope.schema import Tuple
 
-from zope.generic.component import IConfigurationType
-from zope.generic.component import IInformationProvider
-from zope.generic.component import IInformationProviderType
+from zope.generic.configuration import IConfigurationType
+from zope.generic.informationprovider import IInformationProvider
+from zope.generic.informationprovider import IInformationProviderType
 from zope.generic.keyface import IKeyface
+from zope.generic.keyface import IKeyfaceType
 
-from zope.generic.type import ITypeType
 
 
-
 class IContextProxy(Interface):
     """Proxy the context of a component."""
 
@@ -73,7 +71,7 @@
 
 
 
-class IOperationType(IInterface):
+class IOperationType(IKeyfaceType):
     """Mark operation marker interface."""
 
 

Modified: zope.generic/trunk/src/zope/generic/operation/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/metaconfigure.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/operation/metaconfigure.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -22,15 +22,14 @@
 from zope.configuration.exceptions import ConfigurationError
 from zope.interface import alsoProvides
 
-from zope.generic.component.api import queryInformationProvider
-from zope.generic.component.metaconfigure import provideInformationProvider
+from zope.generic.configuration import IConfigurationType
+from zope.generic.configuration import IConfigurations
+from zope.generic.configuration.api import ConfigurationData
+from zope.generic.informationprovider.api import provideInformation
+from zope.generic.informationprovider.api import queryInformation
+from zope.generic.informationprovider.api import queryInformationProvider
+from zope.generic.informationprovider.metaconfigure import provideInformationProvider
 
-from zope.generic.component import IConfigurationType
-from zope.generic.component import IConfigurations
-from zope.generic.component.api import ConfigurationData
-from zope.generic.component.api import provideInformation
-from zope.generic.component.api import queryInformation
-
 from zope.generic.operation import IOperation
 from zope.generic.operation import IOperationConfiguration
 from zope.generic.operation import IOperationInformation

Modified: zope.generic/trunk/src/zope/generic/operation/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/metadirectives.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/operation/metadirectives.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -23,8 +23,8 @@
 from zope.configuration.fields import GlobalObject
 from zope.configuration.fields import Tokens
 
-from zope.generic.component import IConfigurationType
-from zope.generic.component.metadirectives import IBaseInformationProviderDirective
+from zope.generic.configuration import IConfigurationType
+from zope.generic.informationprovider.metadirectives import IBaseInformationProviderDirective
 
 
 

Modified: zope.generic/trunk/src/zope/generic/operation/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/testing.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/operation/testing.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -22,12 +22,13 @@
 
 import zope.app.testing.placelesssetup
 import zope.generic.directlyprovides.testing
-import zope.generic.component.testing
+import zope.generic.configuration.testing
+import zope.generic.informationprovider.testing
 import zope.generic.keyface.testing
 import zope.generic.operation
 import zope.generic.testing.testing
 
-from zope.generic.component.metaconfigure import provideInformationProvider
+from zope.generic.informationprovider.metaconfigure import provideInformationProvider
 from zope.generic.operation import IOperationInformation
 
 
@@ -66,14 +67,16 @@
         zope.generic.testing.testing.setUp(doctest)
         zope.generic.directlyprovides.testing.setUp(doctest)
         zope.generic.keyface.testing.setUp(doctest)
-        zope.generic.component.testing.setUp(doctest)
+        zope.generic.configuration.testing.setUp(doctest)
+        zope.generic.informationprovider.testing.setUp(doctest)
         # internal setup
         setUp(doctest)
 
     def tearDown(self, doctest=None):
         super(PlacelessSetup, self).tearDown()
         # external teardown
-        zope.generic.component.testing.tearDown(doctest)
+        zope.generic.informationprovider.testing.setUp(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)

Modified: zope.generic/trunk/src/zope/generic/type/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/type/DEPENDENCIES.cfg	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/type/DEPENDENCIES.cfg	2006-04-20 14:07:58 UTC (rev 67173)
@@ -1,14 +1,18 @@
 persistent
-zope.generic.component
-zope.generic.directlyprovides
-zope.generic.component
-zope.generic.testing
 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.configuration
+zope.generic.directlyprovides
+zope.generic.informationprovider
+zope.generic.keyface
+zope.generic.testing
 zope.interface
 zope.schema
 zope.security

Modified: zope.generic/trunk/src/zope/generic/type/EXAMPLE.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/type/EXAMPLE.txt	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/type/EXAMPLE.txt	2006-04-20 14:07:58 UTC (rev 67173)
@@ -41,29 +41,32 @@
     ...     note = schema.Text(title=u"Note body", required=False)
 
     >>> registerDirective('''
-    ... <generic:configuration
+    ... <generic:keyface
     ...     keyface="example.ITextConfig"
+    ...     type="zope.generic.configuration.IConfigurationType"
     ...     />
     ... ''') 
 
     >>> registerDirective('''
-    ... <generic:configuration
+    ... <generic:keyface
     ...     keyface="example.INoteConfig"
+    ...     type="zope.generic.configuration.IConfigurationType"
     ...     />
     ... ''')
 
     >>> registerDirective('''
-    ... <generic:configuration
+    ... <generic:keyface
     ...     keyface="example.IArticleInitializationConfiguration"
+    ...     type="zope.generic.configuration.IConfigurationType"
     ...     />
     ... ''')
 
 Step 3: Implement Specific Handlers and the type-specific default data
 ----------------------------------------------------------------------
 
-    >>> from zope.generic.component.api import queryInformation
-    >>> from zope.generic.component.api import provideInformation
-    >>> from zope.generic.component.api import deleteInformation
+    >>> from zope.generic.informationprovider.api import queryInformation
+    >>> from zope.generic.informationprovider.api import provideInformation
+    >>> from zope.generic.informationprovider.api import deleteInformation
     >>> from zope.generic.type.api import queryTypeConfiguration
 
 Let's implement the initializer of the article. Initializers are called from
@@ -90,7 +93,7 @@
     ...     provideInformation(context, INoteConfig, {'body': note})
     ...     deleteInformation(context, IArticleInitializationConfiguration)
  
-    >>> from zope.generic.component.api import ConfigurationData
+    >>> from zope.generic.configuration.api import ConfigurationData
     
     >>> textDefaults = ConfigurationData(ITextConfig, 
     ...     {'body': u"This is the default text."})

Modified: zope.generic/trunk/src/zope/generic/type/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/type/README.txt	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/type/README.txt	2006-04-20 14:07:58 UTC (rev 67173)
@@ -18,7 +18,7 @@
 of instances marked by a certain type marker interface.
 
 The type directive does extend the information directive
-(see zope.generic.component).
+(see zope.generic.configuration).
 
 
 Base type directive
@@ -77,7 +77,7 @@
 retrieve this utility using the conventional utility api:
 
     >>> from zope.component import queryUtility
-    >>> from zope.generic.component.api import toDottedName
+    >>> from zope.generic.keyface.api import toDottedName
 
     >>> info = queryUtility(api.ITypeInformation, toDottedName(IFooMarker))
 
@@ -104,7 +104,7 @@
 
 There are serveral subdirectives like:
 
--	configurations (see zope.generic.component)
+-	configurations (see zope.generic.configuration)
 -	initializer
 
 You can extend type informations by the annotations and configurations mechanism
@@ -127,19 +127,20 @@
     ...		optional = TextLine(title=u'Other', required=False, default=u'Default bla.')
 
     >>> registerDirective('''
-    ... <generic:configuration
+    ... <generic:keyface
     ...     keyface="example.IAnyConfiguration"
-    ...     label='Any' hint='Any bla.'
+    ...     type="zope.generic.configuration.IConfigurationType"
     ...     />
     ... ''') 
 
     >>> registerDirective('''
-    ... <generic:configuration
+    ... <generic:keyface
     ...     keyface="example.IOtherConfiguration"
+    ...     type="zope.generic.configuration.IConfigurationType"
     ...     />
     ... ''') 
 
-	>>> from zope.generic.component.api import ConfigurationData
+	>>> from zope.generic.configuration.api import ConfigurationData
 	>>> typedata = ConfigurationData(IAnyConfiguration, {'any': u'Guguseli from Type!'})
 	>>> IAnyConfiguration.providedBy(typedata)
 	True
@@ -215,7 +216,7 @@
 	>>> api.acquireObjectConfiguration(bar, IOtherConfiguration).other
 	u'Specific initialization data.'
 
-    >>> from zope.generic.component.api import IConfigurations
+    >>> from zope.generic.configuration.api import IConfigurations
 	>>> objectdata = ConfigurationData(IAnyConfiguration, {'any': u'Guguseli from Object!'})
 	>>> IConfigurations(bar)[IAnyConfiguration] = objectdata
 	
@@ -238,7 +239,7 @@
 If we remove the object's configuration the adapter will invoke
 the type configuration, but only the object's configuration can be set:
 
-    >>> from zope.generic.component.api import deleteInformation
+    >>> from zope.generic.informationprovider.api import deleteInformation
     >>> deleteInformation(bar, IAnyConfiguration)
 
     >>> IAnyConfiguration(bar).any

Modified: zope.generic/trunk/src/zope/generic/type/adapter.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/adapter.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/type/adapter.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -23,11 +23,11 @@
 from zope.interface import classImplements
 from zope.interface import implements
 
-from zope.generic.component import IConfigurations
-from zope.generic.component import IConfigurationType
-from zope.generic.component.api import provideInformation
-from zope.generic.component.api import ConfigurationData
+from zope.generic.configuration import IConfigurations
+from zope.generic.configuration import IConfigurationType
+from zope.generic.configuration.api import ConfigurationData
 from zope.generic.keyface import IAttributeKeyfaced
+from zope.generic.informationprovider.api import provideInformation
 
 from zope.generic.type import IInitializer
 from zope.generic.type import IInitializerConfiguration
@@ -151,12 +151,13 @@
     We register the configuration schema using generic:configuration directive:
 
         >>> registerDirective('''
-        ... <generic:configuration
+        ... <generic:keyface
         ...     keyface="example.IFooConfiguration"
+        ...     type="zope.generic.configuration.IConfigurationType"
         ...     />
         ... ''') 
 
-        >>> from zope.generic.component import IConfigurationType
+        >>> from zope.generic.configuration import IConfigurationType
         >>> IConfigurationType.providedBy(IFooConfiguration)
         True
 
@@ -167,7 +168,7 @@
 
         >>>
 
-        >>> from zope.generic.component.api import ConfigurationData
+        >>> from zope.generic.configuration.api import ConfigurationData
 
         >>> foo_configuration = ConfigurationData(IFooConfiguration, {'foo': u'Type Foo'})
 

Modified: zope.generic/trunk/src/zope/generic/type/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/base.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/type/base.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -27,7 +27,7 @@
 from zope.app.container import btree
 from zope.app import folder
 
-from zope.generic.component.api import IAttributeConfigurable
+from zope.generic.configuration.api import IAttributeConfigurable
 from zope.generic.directlyprovides.api import provides
 from zope.generic.directlyprovides.api import UpdateProvides
 from zope.generic.directlyprovides.api import updateDirectlyProvided

Modified: zope.generic/trunk/src/zope/generic/type/configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/type/configure.zcml	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/type/configure.zcml	2006-04-20 14:07:58 UTC (rev 67173)
@@ -4,7 +4,7 @@
   i18n_domain="zope">
 
   <generic:informationProvider
-      keyface="zope.generic.component.IInformationProviderInformation"
+      keyface="zope.generic.informationprovider.IInformationProviderInformation"
       label="Type Information Registry"
       registry=".ITypeInformation"
       />

Modified: zope.generic/trunk/src/zope/generic/type/helper.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/helper.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/type/helper.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -20,9 +20,9 @@
 
 from zope import component
 
-from zope.generic.component.api import toDottedName
-from zope.generic.component.api import queryInformation
-from zope.generic.component.api import queryInformationProvider
+from zope.generic.keyface.api import toDottedName
+from zope.generic.informationprovider.api import queryInformation
+from zope.generic.informationprovider.api import queryInformationProvider
 
 from zope.generic.type import IInitializerConfiguration
 from zope.generic.type import ITypeInformation

Modified: zope.generic/trunk/src/zope/generic/type/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/interfaces.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/type/interfaces.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -21,14 +21,14 @@
 from zope.app.i18n import ZopeMessageFactory as _
 from zope.interface import alsoProvides
 from zope.interface import Interface
-from zope.interface.interfaces import IInterface
 from zope.schema import Bool
 from zope.schema import Object
 
-from zope.generic.component import IConfigurationType
-from zope.generic.component import IInformationProvider
+from zope.generic.configuration import IConfigurationType
 from zope.generic.directlyprovides import IProvides
+from zope.generic.informationprovider import IInformationProvider
 from zope.generic.keyface import IKeyface
+from zope.generic.keyface import IKeyfaceType
 
 
 __all__ = ['ITypeType', 'ITypeable', 'ITyped', 'IDirectlyTyped', 
@@ -37,7 +37,7 @@
 
 
 
-class ITypeType(IInterface):
+class ITypeType(IKeyfaceType):
     """An abstract interface marker marker type.
 
     An interface marked by this marker type will provide an typed information

Modified: zope.generic/trunk/src/zope/generic/type/meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/type/meta.zcml	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/type/meta.zcml	2006-04-20 14:07:58 UTC (rev 67173)
@@ -12,7 +12,7 @@
 
       <meta:subdirective
           name="configuration"
-          schema="zope.generic.component.metadirectives.IConfigurationSubdirective"
+          schema="zope.generic.informationprovider.metadirectives.IConfigurationSubdirective"
           />
 
       <meta:subdirective

Modified: zope.generic/trunk/src/zope/generic/type/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/metaconfigure.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/type/metaconfigure.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -31,10 +31,10 @@
 from zope.security.checker import CheckerPublic
 from zope.security.checker import InterfaceChecker
 
-from zope.generic.component.api import toDottedName
-from zope.generic.component.api import ConfigurationData
-from zope.generic.component.api import provideInformation
-from zope.generic.component.metaconfigure import InformationProviderDirective
+from zope.generic.configuration.api import ConfigurationData
+from zope.generic.informationprovider.api import provideInformation
+from zope.generic.informationprovider.metaconfigure import InformationProviderDirective
+from zope.generic.keyface.api import toDottedName
 
 from zope.generic.type import IInitializationHandler
 from zope.generic.type import IInitializerConfiguration

Modified: zope.generic/trunk/src/zope/generic/type/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/metadirectives.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/type/metadirectives.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -25,7 +25,7 @@
 from zope.configuration.fields import GlobalObject
 from zope.interface import Interface
 
-from zope.generic.component.metadirectives import IBaseInformationProviderDirective
+from zope.generic.informationprovider.metadirectives import IBaseInformationProviderDirective
 
     
 

Modified: zope.generic/trunk/src/zope/generic/type/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/testing.py	2006-04-20 11:52:41 UTC (rev 67172)
+++ zope.generic/trunk/src/zope/generic/type/testing.py	2006-04-20 14:07:58 UTC (rev 67173)
@@ -22,7 +22,7 @@
 
 import zope.app.testing.placelesssetup
 import zope.generic.directlyprovides.testing
-import zope.generic.component.testing
+import zope.generic.configuration.testing
 import zope.generic.keyface.testing
 import zope.generic.testing.testing
 
@@ -61,15 +61,15 @@
         # external setup
         zope.generic.testing.testing.setUp(doctest)
         zope.generic.directlyprovides.testing.setUp(doctest)
-        zope.generic.keyface.testing
-        zope.generic.component.testing.setUp(doctest)
+        zope.generic.keyface.testing.setUp(doctest)
+        zope.generic.configuration.testing.setUp(doctest)
         # internal setup
         setUp(doctest)
 
     def tearDown(self, doctest=None):
         super(PlacelessSetup, self).tearDown()
         # external teardown
-        zope.generic.component.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)



More information about the Checkins mailing list