[Checkins] SVN: zope.generic/trunk/src/zope/generic/ refactored
.information
Dominik Huber
dominik.huber at perse.ch
Mon Apr 10 01:41:08 EDT 2006
Log message for revision 66758:
refactored .information
renamed InformationDeclaration to InterfaceKey
renamed InformationDescription to InterfaceKeyDescription
new .configurator package (work in progress):
- package for initializer and configurationhandler stuff
Changed:
A zope.generic/trunk/src/zope/generic/component/
A zope.generic/trunk/src/zope/generic/component/SETUP.cfg
A zope.generic/trunk/src/zope/generic/component/__init__.py
A zope.generic/trunk/src/zope/generic/component/api.py
A zope.generic/trunk/src/zope/generic/component/base.py
A zope.generic/trunk/src/zope/generic/component/configure.zcml
A zope.generic/trunk/src/zope/generic/component/helper.py
A zope.generic/trunk/src/zope/generic/component/interfaces.py
A zope.generic/trunk/src/zope/generic/component/testing.py
A zope.generic/trunk/src/zope/generic/component/zope.generic.component-configure.zcml
U zope.generic/trunk/src/zope/generic/configuration/adapter.py
U zope.generic/trunk/src/zope/generic/configuration/api.py
U zope.generic/trunk/src/zope/generic/configuration/helper.py
U zope.generic/trunk/src/zope/generic/configuration/interfaces.py
U zope.generic/trunk/src/zope/generic/configuration/metadirectives.py
U zope.generic/trunk/src/zope/generic/configuration/testing.py
A zope.generic/trunk/src/zope/generic/configurator/
A zope.generic/trunk/src/zope/generic/configurator/SETUP.cfg
A zope.generic/trunk/src/zope/generic/configurator/__init__.py
A zope.generic/trunk/src/zope/generic/configurator/configure.zcml
A zope.generic/trunk/src/zope/generic/configurator/interfaces.py
A zope.generic/trunk/src/zope/generic/configurator/zope.generic.configurator-configure.zcml
U zope.generic/trunk/src/zope/generic/directlyprovides/interfaces.py
U zope.generic/trunk/src/zope/generic/information/NEW_README.txt
U zope.generic/trunk/src/zope/generic/information/api.py
U zope.generic/trunk/src/zope/generic/information/base.py
U zope.generic/trunk/src/zope/generic/information/helper.py
U zope.generic/trunk/src/zope/generic/information/interfaces.py
U zope.generic/trunk/src/zope/generic/information/metaconfigure.py
U zope.generic/trunk/src/zope/generic/information/metadirectives.py
U zope.generic/trunk/src/zope/generic/information/testing.py
U zope.generic/trunk/src/zope/generic/type/README.txt
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/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/component/SETUP.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/component/SETUP.cfg 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/component/SETUP.cfg 2006-04-10 05:41:07 UTC (rev 66758)
@@ -0,0 +1,3 @@
+<data-files zopeskel/etc/package-includes>
+ zope.generic.component-*.zcml
+</data-files>
\ No newline at end of file
Property changes on: zope.generic/trunk/src/zope/generic/component/SETUP.cfg
___________________________________________________________________
Name: svn:keywords
+ Id
Added: zope.generic/trunk/src/zope/generic/component/__init__.py
===================================================================
--- zope.generic/trunk/src/zope/generic/component/__init__.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/component/__init__.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -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.component.interfaces import *
\ No newline at end of file
Property changes on: zope.generic/trunk/src/zope/generic/component/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/component/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/component/api.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/component/api.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -0,0 +1,25 @@
+##############################################################################
+#
+# 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.component.base import InterfaceKeyDescription
+from zope.generic.component.helper import getKey
+from zope.generic.component.helper import queryKey
+from zope.generic.component.helper import toComponent
+from zope.generic.component.helper import toDottedName
Property changes on: zope.generic/trunk/src/zope/generic/component/api.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/component/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/component/base.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/component/base.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -0,0 +1,44 @@
+##############################################################################
+#
+# 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 implements
+
+from zope.generic.component import IInterfaceKeyDescription
+
+
+
+class InterfaceKeyDescription(object):
+ """Information description."""
+
+ implements(IInterfaceKeyDescription)
+
+ def __init__(self, interface, label=None, hint=None):
+ self.interface = interface
+
+ if label is None:
+ self.label = _(interface.__name__)
+ else:
+ self.label = label
+
+ if hint is None:
+ self.hint = _(interface.__doc__)
+ else:
+ self.hint = hint
Property changes on: zope.generic/trunk/src/zope/generic/component/base.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/component/configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/component/configure.zcml 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/component/configure.zcml 2006-04-10 05:41:07 UTC (rev 66758)
@@ -0,0 +1,6 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:generic="http://namespaces.zope.org/generic"
+ i18n_domain="zope">
+
+</configure>
Property changes on: zope.generic/trunk/src/zope/generic/component/configure.zcml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/component/helper.py
===================================================================
--- zope.generic/trunk/src/zope/generic/component/helper.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/component/helper.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -0,0 +1,68 @@
+##############################################################################
+#
+# 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
+from zope.interface.interfaces import IInterface
+
+from zope.generic.component import IInterfaceKey
+
+
+
+def toDottedName(component):
+ if component is None:
+ return 'None'
+ return component.__module__ + '.' + component.__name__
+
+
+# cache
+__name_to_component = {}
+
+def toComponent(name):
+ try:
+ return __name_to_component[name]
+ except KeyError:
+ return __name_to_component.setdefault(name, resolve(name))
+
+
+
+def getKey(component):
+ """Evaluate the interface key from a component."""
+
+ if IInterface.providedBy(component):
+ interface = component
+
+ elif IInterfaceKey.providedBy(component):
+ interface = component.interface
+
+ else:
+ interface = IInterfaceKey(component).interface
+
+ return interface
+
+
+
+def queryKey(component, default=None):
+ """Evaluate the interface key from a component."""
+
+ try:
+ return getKey(component)
+
+ except:
+ return default
Property changes on: zope.generic/trunk/src/zope/generic/component/helper.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/component/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/component/interfaces.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/component/interfaces.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -0,0 +1,59 @@
+##############################################################################
+#
+# 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 Interface
+from zope.interface.interfaces import IInterface
+from zope.schema import Object
+from zope.schema import Text
+from zope.schema import TextLine
+
+
+
+class IInterfaceKeyed(Interface):
+ """Provide an interface key by implementation or adaption."""
+
+
+
+class IInterfaceKey(IInterfaceKeyed):
+ """Declare an interface as information-specific-key."""
+
+ interface = Object(
+ title=_('Interface'),
+ description=_('Interface marker that can be used as' +
+ 'interface-specific-key to lookup informations.'),
+ required=True,
+ readonly=True,
+ schema=IInterface)
+
+
+
+class IInterfaceKeyDescription(IInterfaceKey):
+ """Describe the associated interface key."""
+
+ label = TextLine(title=_('Label'),
+ description=_('Label for associated interface marker.'),
+ required=True
+ )
+
+ hint = Text(title=_('Hint'),
+ description=_('Hint explaning the properties of the associated interface marker.'),
+ required=True
+ )
Property changes on: zope.generic/trunk/src/zope/generic/component/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/component/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/component/testing.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/component/testing.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -0,0 +1,70 @@
+##############################################################################
+#
+# 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.configuration.xmlconfig import XMLConfig
+
+import zope.app.testing.placelesssetup
+import zope.generic.directlyprovides.testing
+import zope.generic.testing.testing
+
+################################################################################
+#
+# Public Test implementations
+#
+################################################################################
+
+
+
+################################################################################
+#
+# Placeless setup
+#
+################################################################################
+
+
+
+# specific tests
+def setUp(doctest=None):
+ pass
+
+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)
+ # internal setup
+ setUp(doctest)
+
+ def tearDown(self, doctest=None):
+ super(PlacelessSetup, self).tearDown()
+ # external teardown
+ zope.generic.testing.testing.tearDown(doctest)
+ zope.generic.directlyprovides.testing.tearDown(doctest)
+ # internal teardown
+ tearDown(doctest)
+
+placelesssetup = PlacelessSetup()
Property changes on: zope.generic/trunk/src/zope/generic/component/testing.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/component/zope.generic.component-configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/component/zope.generic.component-configure.zcml 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/component/zope.generic.component-configure.zcml 2006-04-10 05:41:07 UTC (rev 66758)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+ <include package="zope.generic.directlyprovides" />
+
+</configure>
Property changes on: zope.generic/trunk/src/zope/generic/component/zope.generic.component-configure.zcml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: zope.generic/trunk/src/zope/generic/configuration/adapter.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/adapter.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/configuration/adapter.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -28,17 +28,19 @@
from zope.event import notify
from zope.interface import implements
+from zope.generic.component.api import toDottedName
+from zope.generic.component.api import toComponent
+
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 ObjectConfigurationsModifiedEvent
from zope.generic.configuration.helper import configuratonToDict
-from zope.generic.configuration.helper import dottedName
-from zope.generic.configuration.helper import resolveClass
+
class AttributeConfigurations(DictMixin, Location):
"""Store configurations on an object within the __configurations__ attribute.
@@ -60,21 +62,21 @@
return None
else:
- return configurations.get(dottedName(interface), None)
+ return configurations.get(toDottedName(interface), None)
def __getitem__(self, interface):
configurations = getattr(self.context, '__configurations__', None)
if configurations is None:
raise KeyError(interface)
- return configurations[dottedName(interface)]
+ return configurations[toDottedName(interface)]
def keys(self):
configurations = getattr(self.context, '__configurations__', None)
if configurations is None:
return []
- return [resolveClass(iface) for iface in configurations.keys()]
+ return [toComponent(iface) for iface in configurations.keys()]
def update(self, interface, data):
current_config = self[interface]
@@ -120,7 +122,7 @@
configurations = self.context.__configurations__ = OOBTree()
data = configuratonToDict(interface, value, all=True)
- configurations[dottedName(interface)] = value
+ configurations[toDottedName(interface)] = value
# notify setting
parent = self.__parent__
if ILocation.providedBy(parent) and parent.__parent__ is not None:
@@ -133,7 +135,7 @@
except AttributeError:
raise KeyError(interface)
- del configurations[dottedName(interface)]
+ del configurations[toDottedName(interface)]
# notify deletion
# notify setting
parent = self.__parent__
Modified: zope.generic/trunk/src/zope/generic/configuration/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/api.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/configuration/api.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -19,9 +19,7 @@
# usage see README.txt
from zope.generic.configuration.base import ConfigurationData
from zope.generic.configuration.interfaces import *
-from zope.generic.configuration.helper import dottedName
from zope.generic.configuration.helper import provideConfigurationData
from zope.generic.configuration.helper import queryConfigurationData
from zope.generic.configuration.helper import queryConfigurationHandler
from zope.generic.configuration.helper import queryConfigurationInformation
-from zope.generic.configuration.helper import resolveClass
Modified: zope.generic/trunk/src/zope/generic/configuration/helper.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/helper.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/configuration/helper.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -19,9 +19,10 @@
__docformat__ = 'restructuredtext'
-from zope.dottedname.resolve import resolve
from zope.component import getUtility
+from zope.generic.component.api import toDottedName
+
from zope.generic.configuration import IConfigurationHandlerConfiguration
from zope.generic.configuration import IConfigurationHandlerInformation
from zope.generic.configuration import IConfigurationInformation
@@ -29,24 +30,6 @@
-def dottedName(klass):
- if klass is None:
- return 'None'
- return klass.__module__ + '.' + klass.__name__
-
-
-
-# cache
-__name_to_klass = {}
-
-def resolveClass(name):
- try:
- return __name_to_klass[name]
- except KeyError:
- return __name_to_klass.setdefault(name, resolve(name))
-
-
-
def getConfigurationInformation(interface):
return getInformation(interface, IConfigurationInformation)
Modified: zope.generic/trunk/src/zope/generic/configuration/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/interfaces.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/configuration/interfaces.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -20,6 +20,7 @@
from zope.app.event.interfaces import IModificationDescription
from zope.app.event.interfaces import IObjectModifiedEvent
+from zope.app.i18n import ZopeMessageFactory as _
from zope.app.location import ILocation
from zope.interface import Interface
from zope.interface import alsoProvides
@@ -30,19 +31,9 @@
from zope.schema import Object
from zope.schema import Tuple
-from zope.app.i18n import ZopeMessageFactory as _
-
+from zope.generic.component import IInterfaceKey
from zope.generic.information import IInformation
-from zope.generic.information import IInformationDeclaration
-__all__ = ['AnnotationKey', 'IConfigurable', 'IAttributeConfigurable',
- 'IAnnotationsConfigurable', 'IConfigurationType',
- 'IConfigurationModificationDescription',
- 'IObjectConfigurationsModifiedEvent', 'IReadConfigurations',
- 'IUpdateConfigurations', 'IWriteConfigurations', 'IConfigurations',
- 'IConfigurationInformation', 'IConfigurationHandlerInformation',
- 'IConfigurationHandlerType', 'IPrivateHandler',
- 'IConfigurationHandler', 'missing', 'IConfigurationHandlerConfiguration']
@@ -217,7 +208,7 @@
missing = object()
-class IConfigurationHandler(IInformationDeclaration):
+class IConfigurationHandler(IInterfaceKey):
"""A configuration handler.
A handler marked by this type provides a certain configuration procdure
Modified: zope.generic/trunk/src/zope/generic/configuration/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/metadirectives.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/configuration/metadirectives.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -18,10 +18,9 @@
__docformat__ = 'restructuredtext'
+from zope.app.i18n import ZopeMessageFactory as _
from zope.configuration.fields import GlobalObject
-from zope.app.i18n import ZopeMessageFactory as _
-
from zope.generic.information.metadirectives import IBaseInformationDirective
Modified: zope.generic/trunk/src/zope/generic/configuration/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/testing.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/configuration/testing.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -24,6 +24,7 @@
from zope.schema import TextLine
import zope.app.testing.placelesssetup
+import zope.generic.component.testing
import zope.generic.directlyprovides.testing
import zope.generic.information.testing
import zope.generic.testing.testing
@@ -89,6 +90,7 @@
# external setup
zope.generic.testing.testing.setUp(doctest)
zope.generic.directlyprovides.testing.setUp(doctest)
+ zope.generic.component.testing.setUp(doctest)
zope.generic.information.testing.setUp(doctest)
# internal setup
setUp(doctest)
@@ -98,6 +100,7 @@
# external teardown
zope.generic.testing.testing.tearDown(doctest)
zope.generic.directlyprovides.testing.tearDown(doctest)
+ zope.generic.component.testing.tearDown(doctest)
zope.generic.information.testing.tearDown(doctest)
# internal teardown
tearDown(doctest)
Added: zope.generic/trunk/src/zope/generic/configurator/SETUP.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/configurator/SETUP.cfg 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/configurator/SETUP.cfg 2006-04-10 05:41:07 UTC (rev 66758)
@@ -0,0 +1,3 @@
+<data-files zopeskel/etc/package-includes>
+ zope.generic.configurator-*.zcml
+</data-files>
\ No newline at end of file
Property changes on: zope.generic/trunk/src/zope/generic/configurator/SETUP.cfg
___________________________________________________________________
Name: svn:keywords
+ Id
Added: zope.generic/trunk/src/zope/generic/configurator/__init__.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configurator/__init__.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/configurator/__init__.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -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.configurator.interfaces import *
\ No newline at end of file
Property changes on: zope.generic/trunk/src/zope/generic/configurator/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/configurator/configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/configurator/configure.zcml 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/configurator/configure.zcml 2006-04-10 05:41:07 UTC (rev 66758)
@@ -0,0 +1,6 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:generic="http://namespaces.zope.org/generic"
+ i18n_domain="zope">
+
+</configure>
Property changes on: zope.generic/trunk/src/zope/generic/configurator/configure.zcml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/configurator/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configurator/interfaces.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/configurator/interfaces.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -0,0 +1,88 @@
+##############################################################################
+#
+# 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.interface import Interface
+from zope.schema import Object
+
+from zope.generic.configuration import IConfiguraitons
+
+
+
+class IConfigurator(Interface):
+ """Configure an component."""
+
+ def configure(component, *pos, **kws):
+ """Configure the component."""
+
+ configurations = Object(
+ title=_('Configurations'),
+ description=_('The configurations of the component.'),
+ required=False,
+ readonly=True,
+ schema=IConfigurations)
+
+ annotations = Object(
+ title=_('Annotations'),
+ description=_('The annotations of the component.'),
+ required=False,
+ readonly=True,
+ schema=IAnnotations)
+
+
+
+
+class IInitializer(IConfigurator):
+ """Initialize an object."""
+
+
+
+class IInitializationHandler(Interface):
+ """Initialize an object."""
+
+ def __call__(context, *pos, **kws):
+ """Initialize the object referenced by self."""
+
+
+
+class IInitializerConfiguration(Interface):
+ """Provide initialization handler.
+
+ At least a handler or an interface must be defined.
+
+ If the interface is defined, **kws are stored as configuration defined by
+ the interface.
+
+ If the **kws does not satify the interface a KeyError is raised.
+ """
+
+ interface = Object(
+ title=_('Configuration interface'),
+ description=_('Configuration interface defining the signature.'),
+ required=False,
+ schema=IConfigurationType)
+
+ handler = Object(
+ title=_('Initialization Handler'),
+ description=_('Callable (context, *pos, **kws).'),
+ required=False,
+ schema=IInitializationHandler)
+
+alsoProvides(IInitializerConfiguration, IConfigurationType)
Property changes on: zope.generic/trunk/src/zope/generic/configurator/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/configurator/zope.generic.configurator-configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/configurator/zope.generic.configurator-configure.zcml 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/configurator/zope.generic.configurator-configure.zcml 2006-04-10 05:41:07 UTC (rev 66758)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+ <include package="zope.generic.directlyprovides" />
+
+</configure>
Property changes on: zope.generic/trunk/src/zope/generic/configurator/zope.generic.configurator-configure.zcml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: zope.generic/trunk/src/zope/generic/directlyprovides/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/directlyprovides/interfaces.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/directlyprovides/interfaces.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -18,15 +18,14 @@
__docformat__ = 'restructuredtext'
+from zope.app.i18n import ZopeMessageFactory as _
from zope.interface import Attribute
from zope.interface import Interface
from zope.app.event.interfaces import IObjectEvent
-from zope.app.i18n import ZopeMessageFactory as _
-
class IProvides(Interface):
"""Prependes important interfaces within the directly provides mechanism."""
Modified: zope.generic/trunk/src/zope/generic/information/NEW_README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/information/NEW_README.txt 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/information/NEW_README.txt 2006-04-10 05:41:07 UTC (rev 66758)
@@ -90,34 +90,34 @@
>>> from zope.interface import implements
>>> from zope.component import adapts
- >>> from zope.generic.information import IInformationDeclaration
+ >>> from zope.generic.component import IInterfaceKey
>>> class Logger(object):
... """Generic logger adapter."""
... implements(ILogger)
- ... adapts(IInformationDeclaration)
+ ... adapts(IInterfaceKey)
... def __init__(self, context):
... self.context = context
... def log(self, message):
- ... id = IInformationDeclaration(self.context())
+ ... id = IInterfaceKey(self.context())
... info = queryInformation(id.interface, ILogUserInformation)
>>> class Logger(object):
... """Generic logger adapter."""
... implements(ILogger)
- ... adapts(IInformationDeclaration)
+ ... adapts(IInterfaceKey)
... def __init__(self, context):
... self.context = context
... def log(self, message):
- ... id = IInformationDeclaration(self.context())
+ ... id = IInterfaceKey(self.context())
... info = queryInformation(id.interface, ILogUserInformation)
>>> class Logger(object):
... """Generic logger adapter."""
... implements(ILogger)
- ... adapts(IInformationDeclaration)
+ ... adapts(IInterfaceKey)
... def __init__(self, context):
... self.context = context
... def log(self, message):
- ... id = IInformationDeclaration(self.context())
+ ... id = IInterfaceKey(self.context())
... info = queryInformation(id.interface, ILogUserInformation)
Modified: zope.generic/trunk/src/zope/generic/information/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/information/api.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/information/api.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -20,7 +20,6 @@
from zope.generic.information.interfaces import *
from zope.generic.information.base import Information
-from zope.generic.information.helper import dottedName
from zope.generic.information.helper import queryInformation
from zope.generic.information.helper import queryInformationRegistry
from zope.generic.information.helper import registeredInformations
Modified: zope.generic/trunk/src/zope/generic/information/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/information/base.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/information/base.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -19,39 +19,20 @@
__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.component.api import toDottedName
+from zope.generic.component.api import InterfaceKeyDescription
from zope.generic.configuration import IAttributeConfigurable
-from zope.app.i18n import ZopeMessageFactory as _
from zope.generic.information import IInformation
-from zope.generic.information import IInformationDescription
-from zope.generic.information.helper import dottedName
-class InformationDescription(object):
- """Information description."""
- implements(IInformationDescription)
-
- def __init__(self, interface, label=None, hint=None):
- self.interface = interface
-
- if label is None:
- self.label = _(interface.__name__)
- else:
- self.label = label
-
- if hint is None:
- self.hint = _(interface.__doc__)
- else:
- self.hint = hint
-
-
-
-class Information(InformationDescription, dict):
+class Information(InterfaceKeyDescription, dict):
"""Default information.
Information do relate a dedicated type of information marked as an interface
Modified: zope.generic/trunk/src/zope/generic/information/helper.py
===================================================================
--- zope.generic/trunk/src/zope/generic/information/helper.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/information/helper.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -20,25 +20,33 @@
from zope.component import getUtility
from zope.component import getUtilitiesFor
+from zope.interface.interfaces import IInterface
-from zope.generic.configuration.api import resolveClass
+from zope.generic.component import IInterfaceKey
+from zope.generic.component.api import toComponent
+from zope.generic.component.api import toDottedName
from zope.generic.information import IInformationRegistryInformation
-def dottedName(klass):
- if klass is None:
- return 'None'
- return klass.__module__ + '.' + klass.__name__
+def getInformation(object, registry):
+ """Evaluate an information from an object."""
+ if IInterface.providedBy(object):
+ interface = object
+ elif IInterfaceKey.providedBy(object):
+ interface = object.interface
-def getInformation(interface, registry):
- return getUtility(registry, dottedName(interface))
+ else:
+ interface = IInterfaceKey(object).interface
+ #return interface
+ return getUtility(registry, toDottedName(interface))
+
def queryInformation(interface, registry, default=None):
try:
return getInformation(interface, registry)
@@ -55,4 +63,4 @@
def registeredInformations(registry, default=None):
for name, information in getUtilitiesFor(registry):
- yield (resolveClass(name), information)
+ yield (toComponent(name), information)
Modified: zope.generic/trunk/src/zope/generic/information/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/information/interfaces.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/information/interfaces.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -18,6 +18,7 @@
__docformat__ = 'restructuredtext'
+from zope.app.i18n import ZopeMessageFactory as _
from zope.interface import alsoProvides
from zope.interface import Interface
from zope.interface.interfaces import IInterface
@@ -25,37 +26,11 @@
from zope.schema import Text
from zope.schema import TextLine
-from zope.app.i18n import ZopeMessageFactory as _
+from zope.generic.component import IInterfaceKeyDescription
-class IInformationDeclaration(Interface):
- """Declare an interface as information-specific-key."""
-
- interface = Object(
- title=_('Interface'),
- description=_('Interface marker that references corresponding informations.'),
- required=True,
- schema=IInterface)
-
-
-
-class IInformationDescription(IInformationDeclaration):
- """Describe the associated information declaration."""
-
- label = TextLine(title=_('Label'),
- description=_('Label for the registered interface marker.'),
- required=True
- )
-
- hint = Text(title=_('Hint'),
- description=_('Hint explaning the properties of the registered interface marker.'),
- required=True
- )
-
-
-
-class IInformation(IInformationDescription):
+class IInformation(IInterfaceKeyDescription):
"""Inform about an subject referenced by an interface-key.
Additional information can be stored within the information's annotations
Modified: zope.generic/trunk/src/zope/generic/information/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/information/metaconfigure.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/information/metaconfigure.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -23,13 +23,13 @@
from zope.configuration.exceptions import ConfigurationError
from zope.interface import alsoProvides
+from zope.generic.component.api import toDottedName
from zope.generic.configuration.api import IConfigurations
from zope.generic.information import IInformation
from zope.generic.information import IInformationRegistryInformation
from zope.generic.information import IInformationRegistryType
from zope.generic.information.base import Information
-from zope.generic.information.helper import dottedName
from zope.generic.information.helper import queryInformation
@@ -72,7 +72,7 @@
if not registry.providedBy(component):
raise ValueError('Factory must implement %s.' % registry.__name__)
- provideUtility(component, provides=registry, name=dottedName(interface))
+ provideUtility(component, provides=registry, name=toDottedName(interface))
Modified: zope.generic/trunk/src/zope/generic/information/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/information/metadirectives.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/information/metadirectives.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -18,13 +18,12 @@
__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.app.i18n import ZopeMessageFactory as _
-
from zope.generic.information import IInformation
Modified: zope.generic/trunk/src/zope/generic/information/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/information/testing.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/information/testing.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -21,6 +21,7 @@
from zope.configuration.xmlconfig import XMLConfig
import zope.app.testing.placelesssetup
+import zope.generic.component.testing
import zope.generic.directlyprovides.testing
import zope.generic.testing.testing
@@ -58,6 +59,7 @@
# external setup
zope.generic.testing.testing.setUp(doctest)
zope.generic.directlyprovides.testing.setUp(doctest)
+ zope.generic.component.testing.setUp(doctest)
# internal setup
setUp(doctest)
@@ -66,6 +68,7 @@
# external teardown
zope.generic.testing.testing.tearDown(doctest)
zope.generic.directlyprovides.testing.tearDown(doctest)
+ zope.generic.component.testing.tearDown(doctest)
# internal teardown
tearDown(doctest)
Modified: zope.generic/trunk/src/zope/generic/type/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/type/README.txt 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/type/README.txt 2006-04-10 05:41:07 UTC (rev 66758)
@@ -77,9 +77,9 @@
retrieve this utility using the conventional utility api:
>>> from zope.component import queryUtility
- >>> from zope.generic.configuration.api import dottedName
+ >>> from zope.generic.component.api import toDottedName
- >>> info = queryUtility(api.ITypeInformation, dottedName(IFooMarker))
+ >>> info = queryUtility(api.ITypeInformation, toDottedName(IFooMarker))
>>> info.interface == IFooMarker
True
Modified: zope.generic/trunk/src/zope/generic/type/helper.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/helper.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/type/helper.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -20,7 +20,7 @@
from zope import component
-from zope.generic.configuration.api import dottedName
+from zope.generic.component.api import toDottedName
from zope.generic.configuration.api import queryConfigurationData
from zope.generic.information.api import queryInformation
@@ -33,7 +33,7 @@
def createObject(interface, *pos, **kws):
"""Create an instance of a logical type using the type marker."""
- return component.createObject(dottedName(interface), *pos, **kws)
+ return component.createObject(toDottedName(interface), *pos, **kws)
def createParameter(interface):
Modified: zope.generic/trunk/src/zope/generic/type/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/interfaces.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/type/interfaces.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -18,19 +18,20 @@
__docformat__ = 'restructuredtext'
+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 IInterfaceKey
from zope.generic.configuration import IConfigurationHandler
from zope.generic.configuration import IConfigurationType
from zope.generic.directlyprovides import IProvides
-from zope.app.i18n import ZopeMessageFactory as _
from zope.generic.information import IInformation
-from zope.generic.information import IInformationDeclaration
+
__all__ = ['ITypeType', 'ITypeable', 'ITyped', 'IDirectlyTyped',
'ITypeInformation', 'IInitializer', 'IInitializationHandler',
'IInitializerConfiguration']
@@ -51,7 +52,7 @@
-class ITyped(ITypeable, IInformationDeclaration):
+class ITyped(ITypeable, IInterfaceKey):
"""Provid an information within the."""
interface = Object(
@@ -62,7 +63,7 @@
-class IDirectlyTyped(ITyped, IProvides, IInformationDeclaration):
+class IDirectlyTyped(ITyped, IProvides, IInterfaceKey):
"""Directly provide the declared interface."""
def __init__(interface, *pos, **kws):
Modified: zope.generic/trunk/src/zope/generic/type/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/metaconfigure.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/type/metaconfigure.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -30,8 +30,8 @@
from zope.security.checker import CheckerPublic
from zope.security.checker import InterfaceChecker
+from zope.generic.component.api import toDottedName
from zope.generic.configuration.api import ConfigurationData
-from zope.generic.configuration.api import dottedName
from zope.generic.configuration.api import provideConfigurationData
from zope.generic.information.metaconfigure import InformationDirective
@@ -101,7 +101,7 @@
_context.action(
discriminator = ('provideUtility', self._interface),
callable = provideUtility,
- args = (component, IFactory, dottedName(self._interface)),
+ args = (component, IFactory, toDottedName(self._interface)),
)
def initializer(self, _context, interface=None, handler=None):
Modified: zope.generic/trunk/src/zope/generic/type/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/metadirectives.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/type/metadirectives.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -18,12 +18,12 @@
__docformat__ = 'restructuredtext'
+from zope.app.i18n import ZopeMessageFactory as _
from zope.configuration.fields import Bool
from zope.configuration.fields import GlobalInterface
from zope.configuration.fields import GlobalObject
from zope.interface import Interface
-from zope.app.i18n import ZopeMessageFactory as _
from zope.generic.information.metadirectives import IBaseInformationDirective
Modified: zope.generic/trunk/src/zope/generic/type/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/testing.py 2006-04-10 03:58:30 UTC (rev 66757)
+++ zope.generic/trunk/src/zope/generic/type/testing.py 2006-04-10 05:41:07 UTC (rev 66758)
@@ -21,6 +21,7 @@
from zope.configuration.xmlconfig import XMLConfig
import zope.app.testing.placelesssetup
+import zope.generic.component.testing
import zope.generic.configuration.testing
import zope.generic.directlyprovides.testing
import zope.generic.information.testing
@@ -61,6 +62,7 @@
# external setup
zope.generic.testing.testing.setUp(doctest)
zope.generic.directlyprovides.testing.setUp(doctest)
+ zope.generic.component.testing.setUp(doctest)
zope.generic.information.testing.setUp(doctest)
zope.generic.configuration.testing.setUp(doctest)
# internal setup
@@ -71,6 +73,7 @@
# external teardown
zope.generic.testing.testing.tearDown(doctest)
zope.generic.directlyprovides.testing.tearDown(doctest)
+ zope.generic.component.testing.tearDown(doctest)
zope.generic.information.testing.tearDown(doctest)
zope.generic.configuration.testing.tearDown(doctest)
# internal teardown
More information about the Checkins
mailing list