[Checkins] SVN: zope.generic/trunk/src/zope/generic/ rename
.keyface into .face:
Dominik Huber
dominik.huber at perse.ch
Sun Apr 30 18:47:57 EDT 2006
Log message for revision 67773:
rename .keyface into .face:
- differ between context and key interfaces
- rename directive generic:keyface to generic:face
rename .type to .content:
- focus to content components
- divide content registration from information provider (work in progress)
remove .site
Changed:
U zope.generic/trunk/src/zope/generic/adapter/DEPENDENCIES.cfg
U zope.generic/trunk/src/zope/generic/adapter/README.txt
U zope.generic/trunk/src/zope/generic/adapter/adapter.py
U zope.generic/trunk/src/zope/generic/adapter/metaconfigure.py
U zope.generic/trunk/src/zope/generic/adapter/testing.py
U zope.generic/trunk/src/zope/generic/configuration/DEPENDENCIES.cfg
U zope.generic/trunk/src/zope/generic/configuration/PUBLICATION.cfg
U zope.generic/trunk/src/zope/generic/configuration/README.txt
U zope.generic/trunk/src/zope/generic/configuration/adapter.py
U zope.generic/trunk/src/zope/generic/configuration/base.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/testing.py
A zope.generic/trunk/src/zope/generic/content/
A zope.generic/trunk/src/zope/generic/content/DEPENDENCIES.cfg
A zope.generic/trunk/src/zope/generic/content/EXAMPLE.txt
A zope.generic/trunk/src/zope/generic/content/PUBLICATION.cfg
A zope.generic/trunk/src/zope/generic/content/README.txt
A zope.generic/trunk/src/zope/generic/content/SETUP.cfg
A zope.generic/trunk/src/zope/generic/content/TODO.txt
A zope.generic/trunk/src/zope/generic/content/__init__.py
A zope.generic/trunk/src/zope/generic/content/api.py
A zope.generic/trunk/src/zope/generic/content/base.py
A zope.generic/trunk/src/zope/generic/content/configure.zcml
A zope.generic/trunk/src/zope/generic/content/helper.py
A zope.generic/trunk/src/zope/generic/content/interfaces.py
A zope.generic/trunk/src/zope/generic/content/meta.zcml
A zope.generic/trunk/src/zope/generic/content/metaconfigure.py
A zope.generic/trunk/src/zope/generic/content/metadirectives.py
A zope.generic/trunk/src/zope/generic/content/testing.py
A zope.generic/trunk/src/zope/generic/content/tests.py
A zope.generic/trunk/src/zope/generic/content/zope.generic.content-configure.zcml
A zope.generic/trunk/src/zope/generic/content/zope.generic.content-meta.zcml
U zope.generic/trunk/src/zope/generic/directlyprovides/DEPENDENCIES.cfg
A zope.generic/trunk/src/zope/generic/face/
A zope.generic/trunk/src/zope/generic/face/DEPENDENCIES.cfg
A zope.generic/trunk/src/zope/generic/face/PUBLICATION.cfg
A zope.generic/trunk/src/zope/generic/face/README.txt
A zope.generic/trunk/src/zope/generic/face/SETUP.cfg
A zope.generic/trunk/src/zope/generic/face/__init__.py
A zope.generic/trunk/src/zope/generic/face/adapter.py
A zope.generic/trunk/src/zope/generic/face/api.py
A zope.generic/trunk/src/zope/generic/face/base.py
A zope.generic/trunk/src/zope/generic/face/configure.zcml
A zope.generic/trunk/src/zope/generic/face/helper.py
A zope.generic/trunk/src/zope/generic/face/interfaces.py
A zope.generic/trunk/src/zope/generic/face/meta.zcml
A zope.generic/trunk/src/zope/generic/face/metaconfigure.py
A zope.generic/trunk/src/zope/generic/face/metadirectives.py
A zope.generic/trunk/src/zope/generic/face/testing.py
A zope.generic/trunk/src/zope/generic/face/tests.py
A zope.generic/trunk/src/zope/generic/face/zope.generic.face-configure.zcml
A zope.generic/trunk/src/zope/generic/face/zope.generic.face-meta.zcml
U zope.generic/trunk/src/zope/generic/factory/DEPENDENCIES.cfg
U zope.generic/trunk/src/zope/generic/factory/README.txt
U zope.generic/trunk/src/zope/generic/factory/adapter.py
U zope.generic/trunk/src/zope/generic/factory/api.py
U zope.generic/trunk/src/zope/generic/factory/factory.py
U zope.generic/trunk/src/zope/generic/factory/metaconfigure.py
U zope.generic/trunk/src/zope/generic/factory/metadirectives.py
U zope.generic/trunk/src/zope/generic/factory/testing.py
U zope.generic/trunk/src/zope/generic/handler/DEPENDENCIES.cfg
U zope.generic/trunk/src/zope/generic/handler/PUBLICATION.cfg
U zope.generic/trunk/src/zope/generic/handler/README.txt
U zope.generic/trunk/src/zope/generic/handler/metaconfigure.py
U zope.generic/trunk/src/zope/generic/handler/metadirectives.py
U zope.generic/trunk/src/zope/generic/handler/testing.py
U zope.generic/trunk/src/zope/generic/informationprovider/DEPENDENCIES.cfg
U zope.generic/trunk/src/zope/generic/informationprovider/NEW_README.txt
U zope.generic/trunk/src/zope/generic/informationprovider/README.txt
U zope.generic/trunk/src/zope/generic/informationprovider/api.py
U zope.generic/trunk/src/zope/generic/informationprovider/base.py
U zope.generic/trunk/src/zope/generic/informationprovider/interfaces.py
U zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py
U zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py
U zope.generic/trunk/src/zope/generic/informationprovider/testing.py
D zope.generic/trunk/src/zope/generic/keyface/
U 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/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
D zope.generic/trunk/src/zope/generic/site/
U zope.generic/trunk/src/zope/generic/testing/DEPENDENCIES.cfg
D zope.generic/trunk/src/zope/generic/type/
-=-
Modified: zope.generic/trunk/src/zope/generic/adapter/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/DEPENDENCIES.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/adapter/DEPENDENCIES.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -1,13 +1,15 @@
zope.app.component
-zope.location
-zope.app.security
zope.app.testing
zope.component
zope.configuration
+zope.generic.adapter
zope.generic.configuration
zope.generic.directlyprovides
-zope.generic.keyface
+zope.generic.face
+zope.generic.informationprovider
zope.generic.testing
zope.interface
+zope.location
zope.schema
+zope.security
zope.testing
\ No newline at end of file
Modified: zope.generic/trunk/src/zope/generic/adapter/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/README.txt 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/adapter/README.txt 2006-04-30 22:47:53 UTC (rev 67773)
@@ -43,17 +43,17 @@
>>> class IFooConfiguration(interface.Interface):
... foo = TextLine(title=u'Foo', required=False, default=u'Default config.')
-We register the configuration schema using generic:keyface directive:
+We register the configuration schema using generic:face directive:
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IFooConfiguration"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
- >>> from zope.generic.configuration import IConfigurationType
- >>> IConfigurationType.providedBy(IFooConfiguration)
+ >>> from zope.generic.configuration import IConfiguration
+ >>> IConfiguration.providedBy(IFooConfiguration)
True
We implement a class which is providing the configuration mechanism:
@@ -62,7 +62,7 @@
... pass
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IFoo"
... />
... ''')
Modified: zope.generic/trunk/src/zope/generic/adapter/adapter.py
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/adapter.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/adapter/adapter.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -22,7 +22,7 @@
from zope.interface import classImplements
from zope.interface import implements
-from zope.generic.configuration import IConfigurationType
+from zope.generic.configuration import IConfiguration
from zope.generic.configuration import IConfigurations
from zope.generic.adapter.property import ConfigurationAdapterProperty
@@ -52,17 +52,17 @@
>>> class IFooConfiguration(interface.Interface):
... foo = TextLine(title=u'Foo', required=False, default=u'Default config.')
- We register the configuration schema using generic:keyface directive:
+ We register the configuration schema using generic:face directive:
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IFooConfiguration"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
- >>> from zope.generic.configuration import IConfigurationType
- >>> IConfigurationType.providedBy(IFooConfiguration)
+ >>> from zope.generic.configuration import IConfiguration
+ >>> IConfiguration.providedBy(IFooConfiguration)
True
We implement a class which is providing the configuration mechanism:
@@ -71,7 +71,7 @@
... pass
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IFoo"
... />
... ''')
@@ -119,8 +119,8 @@
"""
# preconditions
- if not IConfigurationType.providedBy(keyface):
- raise ValueError('Interface must provide %s.' % IConfigurationType.__name__)
+ if not IConfiguration.providedBy(keyface):
+ raise ValueError('Interface must provide %s.' % IConfiguration.__name__)
# essentails
if not bases:
Modified: zope.generic/trunk/src/zope/generic/adapter/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/metaconfigure.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/adapter/metaconfigure.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -23,7 +23,7 @@
from zope.configuration.exceptions import ConfigurationError
from zope.location import ILocation
-from zope.generic.configuration import IConfigurationType
+from zope.generic.configuration import IConfiguration
from zope.generic.adapter.adapter import ConfigurationAdapterClass
@@ -42,7 +42,7 @@
raise ConfigurationError('Use class or key/ informationProividers attriubte.')
# we will provide a generic adapter class
- if class_ is None and IConfigurationType.providedBy(provides):
+ if class_ is None and IConfiguration.providedBy(provides):
class_ = ConfigurationAdapterClass(provides, informationProviders)
if class_ is None and key:
Modified: zope.generic/trunk/src/zope/generic/adapter/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/adapter/testing.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/adapter/testing.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -22,7 +22,7 @@
import zope.generic.adapter.testing
import zope.generic.configuration.testing
import zope.generic.directlyprovides.testing
-import zope.generic.keyface.testing
+import zope.generic.face.testing
import zope.generic.testing.testing
from zope.configuration.xmlconfig import XMLConfig
@@ -60,7 +60,7 @@
# external setup
zope.generic.testing.testing.setUp(doctest)
zope.generic.directlyprovides.testing.setUp(doctest)
- zope.generic.keyface.testing.setUp(doctest)
+ zope.generic.face.testing.setUp(doctest)
zope.generic.configuration.testing.setUp(doctest)
zope.generic.adapter.testing.setUp(doctest)
# internal setup
@@ -72,7 +72,7 @@
# external teardown
zope.generic.adapter.testing.tearDown(doctest)
zope.generic.configuration.testing.tearDown(doctest)
- zope.generic.keyface.testing.tearDown(doctest)
+ zope.generic.face.testing.tearDown(doctest)
zope.generic.directlyprovides.testing.tearDown(doctest)
zope.generic.testing.testing.tearDown(doctest)
super(PlacelessSetup, self).tearDown()
Modified: zope.generic/trunk/src/zope/generic/configuration/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/DEPENDENCIES.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/configuration/DEPENDENCIES.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -1,13 +1,14 @@
BTrees
persistent
-zope.app.event
-zope.location
zope.app.testing
zope.component
zope.event
+zope.generic.configuration
zope.generic.directlyprovides
-zope.generic.keyface
+zope.generic.face
zope.generic.testing
zope.interface
+zope.lifecycleevent
+zope.location
zope.schema
zope.testing
\ No newline at end of file
Modified: zope.generic/trunk/src/zope/generic/configuration/PUBLICATION.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/PUBLICATION.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/configuration/PUBLICATION.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -5,6 +5,6 @@
Author-email: dominik.huber at perse.ch
License: ZPL 2.1
Description:
- This package offers a mechanism to declare a key interface (IKeyface).
+ This package offers a mechanism to declare a key interface (IFace).
The key interface can be used to lookup corresponding information providers
explicitly.
Modified: zope.generic/trunk/src/zope/generic/configuration/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/README.txt 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/configuration/README.txt 2006-04-30 22:47:53 UTC (rev 67773)
@@ -16,7 +16,7 @@
---------------
Configurations is a container of configuration data. Configuration data are
-defined by an schema which is providing IConfigurationType. The configuration
+defined by an schema which is providing IConfiguration. The configuration
data itself has to provide the schema that is used to reference it.
>>> from zope.schema import TextLine
@@ -25,14 +25,14 @@
... my = TextLine(title=u'My')
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IMyConfiguration"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
- >>> from zope.generic.configuration.api import IConfigurationType
- >>> IConfigurationType.providedBy(IMyConfiguration)
+ >>> from zope.generic.configuration.api import IConfiguration
+ >>> IConfiguration.providedBy(IMyConfiguration)
True
Regularly local configurations are provided by objects marked with
@@ -73,12 +73,12 @@
... 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):
+by IConfiguration (Regularly done by the configuration directive):
>>> from zope.interface import directlyProvides
- >>> directlyProvides(IFooConfiguration, IConfigurationType)
- >>> IConfigurationType.providedBy(IFooConfiguration)
+ >>> directlyProvides(IFooConfiguration, IConfiguration)
+ >>> IConfiguration.providedBy(IFooConfiguration)
True
The configurations provides a regular dictionary api by the UserDictMixin
@@ -98,7 +98,7 @@
[]
... if a value might be set to the configurations it must provide the
-configuration schema itself. This key interface must provide IConfigurationType:
+configuration schema itself. This key interface must provide IConfiguration:
>>> class IBarConfiguration(Interface):
... bar = TextLine(title=u'Bar')
@@ -106,7 +106,7 @@
>>> configurations[IBarConfiguration] = object()
Traceback (most recent call last):
...
- KeyError: 'Interface key IBarConfiguration does not provide IConfigurationType.'
+ KeyError: 'Interface key IBarConfiguration does not provide IConfiguration.'
>>> configurations[IFooConfiguration] = object()
Traceback (most recent call last):
Modified: zope.generic/trunk/src/zope/generic/configuration/adapter.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/adapter.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/configuration/adapter.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -28,11 +28,11 @@
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.face.api import toDottedName
+from zope.generic.face.api import toInterface
from zope.generic.configuration import IAttributeConfigurable
-from zope.generic.configuration import IConfigurationType
+from zope.generic.configuration import IConfiguration
from zope.generic.configuration import IConfigurations
from zope.generic.configuration.event import Configuration
from zope.generic.configuration.event import ObjectConfiguredEvent
@@ -75,7 +75,7 @@
if configurations is None:
return []
- return [toKeyface(iface) for iface in configurations.keys()]
+ return [toInterface(iface) for iface in configurations.keys()]
def update(self, keyface, data):
current_config = self[keyface]
@@ -107,9 +107,9 @@
def __setitem__(self, keyface, value):
# preconditions
- if not IConfigurationType.providedBy(keyface):
+ if not IConfiguration.providedBy(keyface):
raise KeyError('Interface key %s does not provide %s.' %
- (keyface.__name__, IConfigurationType.__name__))
+ (keyface.__name__, IConfiguration.__name__))
if not keyface.providedBy(value):
raise ValueError('Value does not provide %s.' % keyface.__name__)
Modified: zope.generic/trunk/src/zope/generic/configuration/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/base.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/configuration/base.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -27,10 +27,11 @@
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.face import IAttributeFaced
+from zope.generic.face import IFace
+from zope.generic.face.api import FaceForAttributeFaced
+from zope.generic.configuration import IConfiguration
from zope.generic.configuration import IConfigurationData
from zope.generic.configuration import IConfigurations
@@ -97,19 +98,24 @@
...
RuntimeError: ('Data value is not a schema field', 'method')
- The implementation provide an adapter to IKeyface by its __conform__
+ The implementation provide an adapter to IFace by its __conform__
method:
- >>> adapted = IKeyface(config_data)
- >>> IKeyface.providedBy(adapted)
+ >>> adapted = IFace(config_data)
+ >>> IFace.providedBy(adapted)
True
>>> adapted.keyface is IBarConfiguration
True
-
+
+ A configuration belong to the configuration context:
+
+ >>> adapted.conface is IConfiguration
+ True
+
"""
- implements(IAttributeKeyfaced, IConfigurationData)
+ implements(IAttributeFaced, IConfigurationData)
def __init__(self, schema, data):
# preconditions
@@ -126,16 +132,17 @@
# essentials
self.__dict__['_ConfigurationData__data'] = PersistentDict(data)
self.__dict__['__keyface__'] = schema
+ self.__dict__['__conface__'] = IConfiguration
directlyProvides(self, schema)
def __conform__(self, interface):
- if interface is IKeyface:
- return KeyfaceForAttributeKeyfaced(self)
+ if interface is IFace:
+ return FaceForAttributeFaced(self)
def __getattr__(self, name):
- # assert IAttributeKeyfaced
- if name == '__keyface__':
- return self.__dict__['__keyface__']
+ # assert IAttributeFaced
+ if name in ['__keyface__', '__conface__']:
+ return self.__dict__[name]
schema = self.__dict__['__keyface__']
data = self.__dict__['_ConfigurationData__data']
Modified: zope.generic/trunk/src/zope/generic/configuration/helper.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/helper.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/configuration/helper.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -19,7 +19,7 @@
__docformat__ = 'restructuredtext'
-from zope.generic.keyface import IKeyface
+from zope.generic.face import IFace
from zope.generic.configuration.base import ConfigurationData
@@ -53,7 +53,7 @@
"""
data = {}
- keyface = IKeyface(configuration).keyface
+ keyface = IFace(configuration).keyface
for name in keyface:
value = getattr(configuration, name, _marker)
Modified: zope.generic/trunk/src/zope/generic/configuration/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/interfaces.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/configuration/interfaces.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -21,12 +21,13 @@
from zope.location import ILocation
from zope.component.interfaces import IObjectEvent
from zope.interface import Attribute
+from zope.interface import alsoProvides
from zope.interface import Interface
from zope.lifecycleevent.interfaces import IModificationDescription
-from zope.generic.keyface import IKeyfaced
-from zope.generic.keyface import IKeyfaceType
-from zope.generic.keyface import IKeyfaceDescription
+from zope.generic.face import IFaced
+from zope.generic.face import IConfaceType
+from zope.generic.face import IKeyfaceDescription
@@ -35,12 +36,15 @@
-class IConfigurationType(IKeyfaceType):
+class IConfiguration(Interface):
"""Mark a schema that is used for configuration."""
+alsoProvides(IConfiguration, IConfaceType)
-class IConfigurationData(IKeyfaced):
+
+
+class IConfigurationData(IFaced):
"""Marker for configuration data implementations."""
@@ -99,7 +103,7 @@
def __setitem__(keyface, configuration_data):
"""Store a certain configuration data under the interface-key.
- The interface key should provide IConfigurationType.
+ The interface key should provide IConfiguration.
The configuration data has to provide the declared key interface.
Modified: zope.generic/trunk/src/zope/generic/configuration/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/testing.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/configuration/testing.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -21,7 +21,7 @@
import zope.app.testing.placelesssetup
import zope.generic.configuration.testing
import zope.generic.directlyprovides.testing
-import zope.generic.keyface.testing
+import zope.generic.face.testing
import zope.generic.testing.testing
from zope.component import provideAdapter
@@ -60,7 +60,7 @@
fo = TextLine(title=u'Fo', required=False, readonly=True, default=u'fo default')
-class TestKeyfaceAttriute(object):
+class TestAttributeFaced(object):
__keyface__ = IFooConfiguration
@@ -92,7 +92,7 @@
# external setup
zope.generic.testing.testing.setUp(doctest)
zope.generic.directlyprovides.testing.setUp(doctest)
- zope.generic.keyface.testing.setUp(doctest)
+ zope.generic.face.testing.setUp(doctest)
zope.generic.configuration.testing.setUp(doctest)
# internal setup
setUp(doctest)
@@ -103,7 +103,7 @@
tearDown(doctest)
# external teardown
zope.generic.configuration.testing.tearDown(doctest)
- zope.generic.keyface.testing.tearDown(doctest)
+ zope.generic.face.testing.tearDown(doctest)
zope.generic.directlyprovides.testing.tearDown(doctest)
zope.generic.testing.testing.tearDown(doctest)
super(PlacelessSetup, self).tearDown()
Added: zope.generic/trunk/src/zope/generic/content/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/content/DEPENDENCIES.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/DEPENDENCIES.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,20 @@
+persistent
+zope.annotation
+zope.app.container
+zope.app.folder
+zope.app.testing
+zope.component
+zope.configuration
+zope.generic.adapter
+zope.generic.configuration
+zope.generic.content
+zope.generic.directlyprovides
+zope.generic.face
+zope.generic.factory
+zope.generic.handler
+zope.generic.informationprovider
+zope.generic.operation
+zope.generic.testing
+zope.interface
+zope.schema
+zope.testing
\ No newline at end of file
Property changes on: zope.generic/trunk/src/zope/generic/content/DEPENDENCIES.cfg
___________________________________________________________________
Name: svn:keywords
+ Id
Added: zope.generic/trunk/src/zope/generic/content/EXAMPLE.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/content/EXAMPLE.txt 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/EXAMPLE.txt 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,189 @@
+=====================
+Configuration example
+=====================
+
+The example defines an article. The article has a text and a note part.
+
+
+Step 1: Logical Domain Model
+----------------------------
+
+Define the logical domain types and their inheritance. The logical model of our
+domain consist of three types. We use marker interfaces to show their
+inheritance relationships.
+
+ >>> class IText(interface.Interface):
+ ... """Logical text marker"""
+
+ >>> class INote(interface.Interface):
+ ... """Logical note marker"""
+
+ >>> class IArticle(IText, INote):
+ ... """Logical article marker"""
+
+
+Step 2: Building Blocks
+-----------------------
+
+In the generic model these components may be configurations or annotations.
+
+ >>> class ITextConfig(interface.Interface):
+ ... """The text configuration"""
+ ... body = schema.Text(title=u"Text body")
+
+ >>> class INoteConfig(interface.Interface):
+ ... """The note configuration"""
+ ... body = schema.Text(title=u"Text body")
+
+ >>> class IArticleInitializationConfiguration(interface.Interface):
+ ... """The articleconfiguration used for initialization only"""
+ ... text = schema.Text(title=u"Text body")
+ ... note = schema.Text(title=u"Note body", required=False)
+
+ >>> registerDirective('''
+ ... <generic:face
+ ... keyface="example.ITextConfig"
+ ... type="zope.generic.configuration.IConfiguration"
+ ... />
+ ... ''')
+
+ >>> registerDirective('''
+ ... <generic:face
+ ... keyface="example.INoteConfig"
+ ... type="zope.generic.configuration.IConfiguration"
+ ... />
+ ... ''')
+
+ >>> registerDirective('''
+ ... <generic:face
+ ... keyface="example.IArticleInitializationConfiguration"
+ ... type="zope.generic.configuration.IConfiguration"
+ ... />
+ ... ''')
+
+Step 3: Implement Specific Handlers and the type-specific default data
+----------------------------------------------------------------------
+
+ >>> from zope.generic.informationprovider.api import queryInformation
+ >>> from zope.generic.informationprovider.api import provideInformation
+ >>> from zope.generic.informationprovider.api import deleteInformation
+ >>> from zope.generic.content.api import queryTypeConfiguration
+
+Let's implement the initializer of the article. Initializers are called from
+``__init__``. Initializers are used to add additional logic at the
+initialization process.
+
+ >>> def articleInitializer(context, *pos, **kws):
+ ... """Initializer Policy chosen:
+ ... - look up article configuration
+ ... - if there isn't any defined use the base types configuration
+ ... - raises an exception if no configurationis defined
+ ... """
+ ... # looks up the allready configured data on the object
+ ... article_config = queryInformation(context,
+ ... IArticleInitializationConfiguration)
+ ... if article_config is None:
+ ... text_config = queryTypeConfiguration(context, ITextConfig)
+ ... note_config = queryTypeConfiguration(context, INoteConfig)
+ ... text, note = text_config.text, note_config.text
+ ... else:
+ ... text, note = article_config.text, article_config.note
+ ...
+ ... provideInformation(context, ITextConfig, {'body': text})
+ ... provideInformation(context, INoteConfig, {'body': note})
+ ... deleteInformation(context, IArticleInitializationConfiguration)
+
+ >>> from zope.generic.configuration.api import ConfigurationData
+
+ >>> textDefaults = ConfigurationData(ITextConfig,
+ ... {'body': u"This is the default text."})
+
+ >>> noteDefaults = ConfigurationData(INoteConfig,
+ ... {'body': u"This is the default note."})
+
+ >>> articleTextDefaults = ConfigurationData(ITextConfig,
+ ... {'body': u"This is the default article."})
+ >>> articleNoteDefaults = ConfigurationData(INoteConfig,
+ ... {'body': u""})
+
+
+ >>> registerDirective('''
+ ... <generic:content
+ ... keyface="example.IText"
+ ... >
+ ... <factory
+ ... class='zope.generic.content.api.Object'
+ ... input='example.ITextConfig'
+ ... />
+ ... <information
+ ... keyface='example.ITextConfig'
+ ... configuration='example.textDefaults'
+ ... />
+ ... </generic:content>
+ ... ''')
+
+ >>> registerDirective('''
+ ... <generic:content
+ ... keyface="example.INote"
+ ... >
+ ... <factory
+ ... class='zope.generic.content.api.Object'
+ ... input='example.INoteConfig'
+ ... />
+ ... <information
+ ... keyface='example.INoteConfig'
+ ... configuration='example.noteDefaults'
+ ... />
+ ... </generic:content>
+ ... ''')
+
+ >>> registerDirective('''
+ ... <generic:content
+ ... keyface="example.IArticle"
+ ... >
+ ... <factory
+ ... class='zope.generic.content.api.Object'
+ ... input='example.IArticleInitializationConfiguration'
+ ... operations='example.articleInitializer'
+ ... storeInput='True'
+ ... />
+ ... <information
+ ... keyface='example.ITextConfig'
+ ... configuration='example.articleTextDefaults'
+ ... />
+ ... <information
+ ... keyface='example.INoteConfig'
+ ... configuration='example.articleNoteDefaults'
+ ... />
+ ... </generic:content>
+ ... ''')
+
+
+Step 4: Enjoy your logical domain...
+------------------------------------
+
+To create an article we use the logical domain interface
+
+ >>> from zope.generic.content.api import createObject
+
+ >>> article = createObject(IArticle)
+ Traceback (most recent call last):
+ ...
+ TypeError: __init__ requires 'text' of 'IArticleInitializationConfiguration'.
+
+ >>> article = createObject(IArticle, u"First version of article.")
+
+ >>> IArticle.providedBy(article)
+ True
+
+ >>> queryInformation(article, ITextConfig).body
+ u'First version of article.'
+
+ >>> queryInformation(article, IArticleInitializationConfiguration).text
+ Traceback (most recent call last):
+ ...
+ AttributeError: 'NoneType' object has no attribute 'text'
+
+ #>>> IText(article, None)
+ #>>> INote(article, None)
+
\ No newline at end of file
Property changes on: zope.generic/trunk/src/zope/generic/content/EXAMPLE.txt
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/PUBLICATION.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/content/PUBLICATION.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/PUBLICATION.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,9 @@
+Metadata-Version: 1.0
+Name: zope.generic.informed
+Summary: Provide a logical type facility
+Author: Dominik Huber, Perse Engineering GmbH, Switzerland
+Author-email: dominik.huber at perse.ch
+License: ZPL 2.1
+Description:
+ An object provides often serval interfaces. This package provides a
+ interace based type assoziation in a way like *classes* or *types* do.
Property changes on: zope.generic/trunk/src/zope/generic/content/PUBLICATION.cfg
___________________________________________________________________
Name: svn:keywords
+ Id
Added: zope.generic/trunk/src/zope/generic/content/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/content/README.txt 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/README.txt 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,277 @@
+====
+Type
+====
+
+An object provides often serval interfaces. This package provides a interace
+based type assoziation in a way like *classes* or *types* do. Typeable object
+provides by adaption or implementation access to a type marker. This type
+marker can be used to lookup further information about the referenced type.
+
+For each interface typed by our type marker type (ITypeType) we provied a type
+factory that can create instaces of this certain *logical* type.
+
+Furthermore a type information utility will be provided. This type information
+allows to annotate additonal stuff like using the annotations and configurations
+mechanism.
+
+Informations provided by the type information should be accounted by the handling
+of instances marked by a certain type marker interface.
+
+The type directive does extend the information directive
+(see zope.generic.configuration).
+
+
+Base type directive
+-------------------
+
+In our example we register type using the generic:content directive. Therefore we
+need an type marker:
+
+ >>> class IFooMarker(interface.Interface):
+ ... pass
+
+The only thing to register a specific logical type is this type marker interface.
+The package offers four different generic implementation such as Object,
+Contained, Container and Folder (Site) that you might use as implementation of
+your logical type. Certainly you can provide your own implementation. Such an
+implementation should implement at least the marker ITypeable and a corresponding
+adapter to ITyped.
+
+In our example we will use a simple generic object:
+
+ >>> from zope.generic.content import api
+ >>> api.ITypeable.implementedBy(api.Object)
+ True
+ >>> api.IGenericTyped.implementedBy(api.Object)
+ True
+
+ >>> registerDirective('''
+ ... <generic:content
+ ... keyface="example.IFooMarker"
+ ... label='Foo Type' hint='Bla bla bla.'
+ ... >
+ ... <factory class='zope.generic.content.api.Object'
+ ... />
+ ... </generic:content>
+ ... ''')
+
+After the typed is registered the type marker will provide ITypeType:
+
+ >>> from zope.generic.content import api
+
+ >>> api.ITypeType.providedBy(IFooMarker)
+ True
+
+You can create instances of the registered logical type:
+
+ >>> foo = api.createObject(IFooMarker)
+ >>> typed = api.ITyped(foo)
+ >>> typed.keyface == IFooMarker
+ True
+
+In our example we use a generic directly typed implementation. In those cases
+the instance will provide the type marker too:
+
+ >>> IFooMarker.providedBy(foo)
+ True
+
+A corresponding type information utility will be available. Your can
+retrieve this utility using the conventional utility api:
+
+ >>> from zope.component import queryUtility
+ >>> from zope.generic.face.api import toDottedName
+
+ >>> info = queryUtility(api.ITypeInformation, toDottedName(IFooMarker))
+
+ >>> info.keyface == IFooMarker
+ True
+ >>> info.label
+ u'Foo Type'
+ >>> info.hint
+ u'Bla bla bla.'
+
+There is convenience function for the lookup of corresponding type information.
+You can lookup the type information by the type marker interface or an object
+providing ITyped by implementation or adaption:
+
+ >>> api.queryTypeInformation(IFooMarker) == info
+ True
+
+ >>> api.queryTypeInformation(foo) == info
+ True
+
+
+Type subdirectives
+------------------
+
+There are serveral subdirectives like:
+
+- configurations (see zope.generic.configuration)
+- initializer
+
+You can extend type informations by the annotations and configurations mechanism
+like the information will do.
+
+First we will provide a new bar type including an additional configuration:
+
+ >>> class IBarMarker(interface.Interface):
+ ... pass
+
+Then we provide two example configurations for our example:
+
+ >>> from zope.schema import TextLine
+
+ >>> class IAnyConfiguration(interface.Interface):
+ ... any = TextLine(title=u'Any')
+
+ >>> class IOtherConfiguration(interface.Interface):
+ ... other = TextLine(title=u'Other')
+ ... optional = TextLine(title=u'Other', required=False, default=u'Default bla.')
+
+ >>> registerDirective('''
+ ... <generic:face
+ ... keyface="example.IAnyConfiguration"
+ ... type="zope.generic.configuration.IConfiguration"
+ ... />
+ ... ''')
+
+ >>> registerDirective('''
+ ... <generic:face
+ ... keyface="example.IOtherConfiguration"
+ ... type="zope.generic.configuration.IConfiguration"
+ ... />
+ ... ''')
+
+ >>> from zope.generic.configuration.api import ConfigurationData
+ >>> typedata = ConfigurationData(IAnyConfiguration, {'any': u'Guguseli from Type!'})
+ >>> IAnyConfiguration.providedBy(typedata)
+ True
+
+We can provide a specific intializer handler:
+
+ >>> def barInitializer(context, *pos, **kws):
+ ... print 'Initializing bar'
+
+Additionaly we can add other operation base object event handlers:
+
+ >>> def objectEventHandler(context, event):
+ ... print 'Guguseli from object event.'
+
+
+After all we register our component using the type directive:
+
+ >>> registerDirective('''
+ ... <generic:content
+ ... keyface="example.IBarMarker"
+ ... label='Bar Type' hint='Bla bla bla.'
+ ... >
+ ... <factory
+ ... class='zope.generic.content.api.Object'
+ ... input='example.IOtherConfiguration'
+ ... operations='example.barInitializer'
+ ... storeInput='True'
+ ... />
+ ... <information
+ ... keyface='example.IAnyConfiguration'
+ ... configuration='example.typedata'
+ ... />
+ ... <adapter
+ ... provides='example.IAnyConfiguration'
+ ... acquire='True'
+ ... />
+ ... <handler
+ ... event='zope.component.interfaces.IObjectEvent'
+ ... operations='example.objectEventHandler'
+ ... />
+ ... </generic:content>
+ ... ''')
+
+Now we can create an instance of the logical type. We defined an initializer
+interface. Doing the **kws parameter are stored as configuration to the object.
+If we do not satify the declaration an KeyError is raised:
+
+ >>> api.createParameter(IBarMarker) == IOtherConfiguration
+ True
+
+ >>> bar = api.createObject(IBarMarker)
+ Traceback (most recent call last):
+ ...
+ TypeError: __init__ requires 'other' of 'IOtherConfiguration'.
+
+ >>> bar = api.createObject(IBarMarker, other=u'Specific initialization data.')
+ Guguseli from object event.
+ Initializing bar
+
+This registration attached the specific configuration to the type information.
+You can retrieve type information by a typed instance or the marker type itself
+using the following convenience function:
+
+ >>> api.queryTypeConfiguration(IBarMarker, IAnyConfiguration).any
+ u'Guguseli from Type!'
+
+ >>> api.queryTypeConfiguration(bar, IAnyConfiguration).any
+ u'Guguseli from Type!'
+
+ >>> api.queryTypeConfiguration(IBarMarker, IOtherConfiguration) is None
+ True
+
+This configuration is type specific. You cannot lookup any object- or
+instance-specific configuration, but you can use a function that `acquires`
+different configurations:
+
+ >>> api.queryObjectConfiguration(bar, IAnyConfiguration) is None
+ True
+
+ >>> api.queryObjectConfiguration(bar, IOtherConfiguration).other
+ u'Specific initialization data.'
+
+ >>> api.acquireObjectConfiguration(bar, IAnyConfiguration).any
+ u'Guguseli from Type!'
+
+ >>> api.acquireObjectConfiguration(bar, IOtherConfiguration).other
+ u'Specific initialization data.'
+
+ >>> from zope.generic.configuration.api import IConfigurations
+ >>> objectdata = ConfigurationData(IAnyConfiguration, {'any': u'Guguseli from Object!'})
+ >>> IConfigurations(bar)[IAnyConfiguration] = objectdata
+
+ >>> api.queryObjectConfiguration(bar, IAnyConfiguration).any
+ u'Guguseli from Object!'
+
+ >>> api.acquireObjectConfiguration(bar, IAnyConfiguration).any
+ u'Guguseli from Object!'
+
+The configurationAdapter subdirective provides an adapter too:
+
+ >>> IOtherConfiguration(bar)
+ Traceback (most recent call last):
+ ...
+ TypeError: ('Could not adapt', ... example.IOtherConfiguration>)
+
+ >>> IAnyConfiguration(bar).any
+ u'Guguseli from Object!'
+
+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.informationprovider.api import deleteInformation
+ >>> deleteInformation(bar, IAnyConfiguration)
+
+ >>> IAnyConfiguration(bar).any
+ u'Guguseli from Type!'
+
+ >>> IAnyConfiguration(bar).any = u'Guguseli from Object another time!'
+ >>> IAnyConfiguration(bar).any
+ u'Guguseli from Object another time!'
+
+Now we like to invoke an type-specific event handler:
+
+ >>> from zope.component.interfaces import IObjectEvent
+ >>> from zope.component.interfaces import ObjectEvent
+ >>> from zope.event import notify
+
+ >>> event = ObjectEvent(bar)
+ >>> notify(event)
+ Guguseli from object event.
+
+ >>> notify(ObjectEvent(object()))
\ No newline at end of file
Property changes on: zope.generic/trunk/src/zope/generic/content/README.txt
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/SETUP.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/content/SETUP.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/SETUP.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,3 @@
+<data-files zopeskel/etc/package-includes>
+ zope.generic.content-*.zcml
+</data-files>
\ No newline at end of file
Property changes on: zope.generic/trunk/src/zope/generic/content/SETUP.cfg
___________________________________________________________________
Name: svn:keywords
+ Id
Added: zope.generic/trunk/src/zope/generic/content/TODO.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/content/TODO.txt 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/TODO.txt 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,26 @@
+====
+TODO
+====
+
+ logical type
+ >>> class IFoo(Interface):
+ ... """IFoo bla."""
+
+ >>> foo = api.createObject(IFoo)
+
+ >>> foo.__keyface__ == IFoo
+ True
+ >>> IFace(foo) == IFoo
+ True
+ >>> type_registration = IType(foo) # heute type_information
+ >>> type_registration.__keyface__ == IFoo
+ True
+ >>> type_registration.label
+ u'example.IFoo'
+ >>> type_registration.hint
+ u'Foo bla'
+ >>> IConfigurations.providedBy(type_registration)
+ True
+ >>> any_type_config = IAnyConfig(type_registration)
+ >>> IAnyConfig.providedBy(any_type_config)
+ True
\ No newline at end of file
Property changes on: zope.generic/trunk/src/zope/generic/content/TODO.txt
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/__init__.py
===================================================================
--- zope.generic/trunk/src/zope/generic/content/__init__.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/__init__.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -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.content.interfaces import *
\ No newline at end of file
Property changes on: zope.generic/trunk/src/zope/generic/content/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/content/api.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/api.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,32 @@
+##############################################################################
+#
+# 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$
+"""
+
+# usage see README.txt
+from zope.generic.factory.api import createObject
+from zope.generic.factory.api import createParameter
+from zope.generic.content.interfaces import *
+from zope.generic.content.base import Object
+from zope.generic.content.base import Contained
+from zope.generic.content.base import Container
+from zope.generic.content.base import Folder
+from zope.generic.content.base import OrderedContainer
+
+from zope.generic.content.helper import acquireObjectConfiguration
+from zope.generic.content.helper import queryObjectConfiguration
+from zope.generic.content.helper import queryTypeConfiguration
+from zope.generic.content.helper import queryTypeInformation
Property changes on: zope.generic/trunk/src/zope/generic/content/api.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/content/base.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/base.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,122 @@
+##############################################################################
+#
+# 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 zope.interface import implements
+
+from zope.app.container import contained
+from zope.app.container import btree
+from zope.app.container import ordered
+from zope.app import folder
+
+from zope.generic.directlyprovides.api import provides
+from zope.generic.directlyprovides.api import UpdateProvides
+
+from zope.generic.content import IGenericTyped
+
+
+
+class Object(object):
+ """Default implementation for simple objects."""
+
+ implements(IGenericTyped)
+
+ def __init__(self, *pos, **kws):
+ super(Object, self).__init__()
+
+ provides('__keyface__')
+
+ __keyface__ = UpdateProvides(IGenericTyped['__keyface__'])
+
+ @property
+ def keyface(self):
+ return self.__keyface__
+
+
+
+class Contained(contained.Contained, Persistent):
+ """Default implementation local, persistend and contained objects."""
+
+ implements(IGenericTyped)
+
+ def __init__(self, *pos, **kws):
+ super(Contained, self).__init__()
+
+ provides('__keyface__')
+
+ __keyface__ = UpdateProvides(IGenericTyped['__keyface__'])
+
+ @property
+ def keyface(self):
+ return self.__keyface__
+
+
+class Container(btree.BTreeContainer):
+ """Default implementation local, persistend and containerish objects."""
+
+ implements(IGenericTyped)
+
+ def __init__(self, *pos, **kws):
+ super(Container, self).__init__()
+
+ provides('__keyface__')
+
+ __keyface__ = UpdateProvides(IGenericTyped['__keyface__'])
+
+ @property
+ def keyface(self):
+ return self.__keyface__
+
+
+
+class OrderedContainer(ordered.OrderedContainer):
+ """Default implementation local, persistend and ordered-containerish objects."""
+
+ implements(IGenericTyped)
+
+ def __init__(self, *pos, **kws):
+ super(OrderedContainer, self).__init__()
+
+ provides('__keyface__')
+
+ __keyface__ = UpdateProvides(IGenericTyped['__keyface__'])
+
+ @property
+ def keyface(self):
+ return self.__keyface__
+
+
+
+class Folder(folder.Folder):
+ """Default implementation local, persistend and containerish possible sites."""
+
+ implements(IGenericTyped)
+
+ def __init__(self, *pos, **kws):
+ super(Folder, self).__init__()
+
+ provides('__keyface__')
+
+ __keyface__ = UpdateProvides(IGenericTyped['__keyface__'])
+
+ @property
+ def keyface(self):
+ return self.__keyface__
Property changes on: zope.generic/trunk/src/zope/generic/content/base.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/content/configure.zcml 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/configure.zcml 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,103 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:apidoc="http://namespaces.zope.org/apidoc"
+ xmlns:generic="http://namespaces.zope.org/generic"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ i18n_domain="zope">
+
+ <apidoc:bookchapter zcml:condition="have apidoc"
+ id="zope.generic.content.readme"
+ title="Type"
+ doc_path="README.txt"
+ parent="zope.generic"
+ />
+
+ <apidoc:bookchapter zcml:condition="have apidoc"
+ id="zope.generic.content.example"
+ title="Type (Example)"
+ doc_path="EXAMPLE.txt"
+ parent="zope.generic"
+ />
+
+ <generic:informationProvider
+ keyface="zope.generic.informationprovider.IInformationProviderInformation"
+ label="Type Information Registry"
+ registry=".ITypeInformation"
+ />
+
+ <!-- transient generic object implementation -->
+ <class class=".base.Object">
+ <require
+ permission="zope.Public"
+ interface="zope.generic.content.ITyped"
+ />
+ </class>
+
+ <!-- persistent generic contained implementation -->
+ <class class=".base.Contained">
+ <require
+ permission="zope.Public"
+ interface="zope.generic.content.ITyped"
+ />
+ </class>
+
+ <!-- persistent generic container implementation -->
+ <class class=".base.Container">
+ <require
+ permission="zope.Public"
+ interface="zope.generic.content.ITyped"
+ />
+ <require
+ permission="zope.View"
+ interface="zope.app.container.interfaces.IReadContainer"
+ />
+ <require
+ permission="zope.ManageContent"
+ interface="zope.app.container.interfaces.IWriteContainer"
+ />
+ </class>
+
+ <!-- persistent generic ordered container implementation -->
+ <class class=".base.OrderedContainer">
+ <require
+ permission="zope.Public"
+ interface="zope.generic.content.ITyped"
+ />
+ <require
+ permission="zope.View"
+ interface="zope.app.container.interfaces.IReadContainer"
+ />
+ <require
+ permission="zope.ManageContent"
+ interface="zope.app.container.interfaces.IWriteContainer"
+ />
+ <require
+ permission="zope.ManageContent"
+ attributes="updateOrder"
+ />
+ </class>
+
+ <!-- persistent generic folder implementation -->
+ <class class=".base.Folder">
+ <require
+ permission="zope.Public"
+ interface="zope.generic.content.ITyped"
+ />
+ <require
+ permission="zope.View"
+ interface="zope.app.container.interfaces.IReadContainer"
+ />
+ <require
+ permission="zope.ManageContent"
+ interface="zope.app.container.interfaces.IWriteContainer"
+ />
+ <allow
+ attributes="getSiteManager"
+ />
+ <require
+ permission="zope.ManageSite"
+ attributes="setSiteManager"
+ />
+ </class>
+
+</configure>
Property changes on: zope.generic/trunk/src/zope/generic/content/configure.zcml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/helper.py
===================================================================
--- zope.generic/trunk/src/zope/generic/content/helper.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/helper.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,100 @@
+##############################################################################
+#
+# 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.informationprovider.api import queryInformation
+from zope.generic.informationprovider.api import getInformationProvider
+
+from zope.generic.content import ITypeInformation
+from zope.generic.content import ITyped
+from zope.generic.content import ITypeType
+
+
+
+def getType(object):
+ """Evaluate relevant type marker keyface of an object."""
+
+ if ITypeType.providedBy(object):
+ keyface = object
+
+ elif ITyped.providedBy(object):
+ keyface = object.keyface
+
+ else:
+ keyface = ITyped(object).keyface
+
+ return keyface
+
+
+
+def queryType(object, default=None):
+ try:
+ return getType(object)
+
+ except:
+ return default
+
+
+
+def getTypeInformation(object):
+ return getInformationProvider(getType(object), ITypeInformation)
+
+
+
+def queryTypeInformation(object, default=None):
+ """Lookup an type information of any object."""
+
+ try:
+ return getTypeInformation(object)
+
+ except:
+ return default
+
+
+
+def queryObjectConfiguration(object, configuration, default=None):
+ return queryInformation(object, configuration, default)
+
+
+
+def queryTypeConfiguration(object, configuration, default=None):
+ info = queryTypeInformation(object)
+ return queryInformation(info, configuration, default)
+
+
+
+def acquireTypeConfiguration(object, configuration, default=None):
+ try:
+ keyface = getType(object, default)
+
+ except:
+ return default
+
+
+
+def acquireObjectConfiguration(object, configuration, default=None):
+ # first try to evaluate object configuration data
+ data = queryObjectConfiguration(object, configuration, default)
+
+ if data is not default:
+ return data
+
+ # return type configuration data
+ else:
+ return queryTypeConfiguration(object, configuration, default)
Property changes on: zope.generic/trunk/src/zope/generic/content/helper.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/content/interfaces.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/interfaces.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -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.annotation.interfaces import IAttributeAnnotatable
+from zope.app.i18n import ZopeMessageFactory as _
+from zope.interface import Interface
+from zope.schema import Object
+
+from zope.generic.configuration.api import IAttributeConfigurable
+from zope.generic.informationprovider import IInformationProvider
+from zope.generic.face import IFace
+from zope.generic.face import IKeyfaceType
+from zope.generic.face import IProvidesAttributeFaced
+
+
+__all__ = ['ITypeType', 'ITypeable', 'ITyped', 'IGenericTyped',
+ 'ITypeInformation']
+
+
+
+class ITypeType(IKeyfaceType):
+ """An abstract interface marker marker type.
+
+ An interface marked by this marker type will provide an typed information
+ within the corresponding ITypeInformation registry.
+ """
+
+
+
+class ITypeable(Interface):
+ """Assert ITyped by adaption or by implementation."""
+
+
+
+class ITyped(ITypeable, IFace):
+ """Provide the key interface."""
+
+ keyface = Object(
+ title=_('Key interface'),
+ description=_('Key interface that references corresponding type informations.'),
+ required=True,
+ schema=ITypeType)
+
+
+
+class IGenericTyped(ITyped, IProvidesAttributeFaced, IAttributeConfigurable, IAttributeAnnotatable):
+ """Directly provide the declared key interface interface."""
+
+
+
+class ITypeInformation(IInformationProvider):
+ """Provide information for the declared type interface."""
+
Property changes on: zope.generic/trunk/src/zope/generic/content/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/content/meta.zcml 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/meta.zcml 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,37 @@
+<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="content"
+ schema=".metadirectives.ITypeDirective"
+ handler=".metaconfigure.TypeDirective"
+ >
+
+ <meta:subdirective
+ name="information"
+ schema="zope.generic.informationprovider.metadirectives.IInformationSubdirective"
+ />
+
+ <meta:subdirective
+ name="factory"
+ schema=".metadirectives.IFactorySubdirective"
+ />
+
+ <meta:subdirective
+ name="adapter"
+ schema=".metadirectives.IAdapterSubdirective"
+ />
+
+ <meta:subdirective
+ name="handler"
+ schema=".metadirectives.IHandlerSubdirective"
+ />
+
+ </meta:complexDirective>
+
+ </meta:directives>
+
+</configure>
Property changes on: zope.generic/trunk/src/zope/generic/content/meta.zcml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/content/metaconfigure.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/metaconfigure.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -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.exceptions import ConfigurationError
+
+from zope.generic.adapter.metaconfigure import adapterDirective
+from zope.generic.factory.metaconfigure import factoryDirective
+from zope.generic.informationprovider.metaconfigure import InformationProviderDirective
+from zope.generic.handler.metaconfigure import handlerDirective
+
+from zope.generic.content import ITypeInformation
+from zope.generic.content import ITypeType
+
+
+
+class TypeDirective(InformationProviderDirective):
+ """Provide a new logical type."""
+
+ # mark types with a type marker type
+ _information_type = ITypeType
+
+
+ def __init__(self, _context, keyface, label=None, hint=None):
+ # register types within the type information registry
+ registry = ITypeInformation
+ super(TypeDirective, self).__init__(_context, keyface, registry, label, hint)
+
+ def factory(self, _context, class_, operations=(), input=None,
+ providesFace=True, notifyCreated=False, storeInput=False):
+ """Add factory."""
+ factoryDirective(_context, self._keyface, class_, None, operations, input,
+ providesFace, notifyCreated, storeInput,
+ self._label, self._hint)
+
+
+ def adapter(self, _context, provides, class_=None, writePermission=None,
+ readPermission=None, attributes=None, set_attributes=None,
+ key=None, informationProviders=None, acquire=False):
+ """Provide a generic adatper for the key interface."""
+
+ if informationProviders and acquire:
+ raise ConfigurationError('Use informationsProviders or acquire attriubte.')
+
+ if acquire:
+ informationProviders = [ITypeInformation]
+
+ adapterDirective(_context, provides, [self._keyface], class_,
+ writePermission, readPermission, attributes,
+ set_attributes, key, informationProviders,)
+
+ def handler(self, _context, event, operations=(), input=None):
+ """Provide a object event handler."""
+ handlerDirective(_context, self._keyface, event, operations, input)
Property changes on: zope.generic/trunk/src/zope/generic/content/metaconfigure.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/content/metadirectives.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/metadirectives.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,64 @@
+##############################################################################
+#
+# 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 Bool
+
+from zope.generic.adapter.metadirectives import IOthersAdapterDirective
+from zope.generic.factory.metadirectives import IBaseFactoryDirective
+from zope.generic.informationprovider.metadirectives import IBaseInformationProviderDirective
+from zope.generic.handler.metadirectives import IBaseHandlerDirective
+from zope.generic.operation.metadirectives import IBaseOperationDirective
+
+
+
+class ITypeDirective(IBaseInformationProviderDirective):
+ """Declare attriubtes of the type directive.
+
+ Register an type information and a type factory.
+ """
+
+
+
+class IFactorySubdirective(IBaseFactoryDirective, IBaseOperationDirective):
+ """Provide an factory for the type."""
+
+ providesFace = Bool(
+ title=_('Provides Face'),
+ description=_('If the class does not implement the key interface '
+ 'directly provide it to the instances '
+ 'before initalization.'),
+ required=False,
+ default=True
+ )
+
+
+class IAdapterSubdirective(IOthersAdapterDirective):
+ """Provide an adapter for the key interface."""
+
+ acquire = Bool(
+ title=_('Acquire Type Information'),
+ description=_('If selected the type information are invoked.'),
+ required=False,
+ default=False
+ )
+
+class IHandlerSubdirective(IBaseHandlerDirective, IBaseOperationDirective):
+ """Provide object event handler for the keyface."""
Property changes on: zope.generic/trunk/src/zope/generic/content/metadirectives.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/content/testing.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/testing.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,93 @@
+##############################################################################
+#
+# 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
+import zope.generic.adapter.testing
+import zope.generic.configuration.testing
+import zope.generic.directlyprovides.testing
+import zope.generic.factory.testing
+import zope.generic.handler.testing
+import zope.generic.face.testing
+import zope.generic.operation.testing
+import zope.generic.testing.testing
+
+from zope.configuration.xmlconfig import XMLConfig
+
+
+
+################################################################################
+#
+# Public Test implementations
+#
+################################################################################
+
+def testInitializer(context, *pos, **kws):
+ print context, pos, kws
+
+
+
+################################################################################
+#
+# Placeless setup
+#
+################################################################################
+
+# specific tests
+def setUp(doctest=None):
+ # register the directive of this package
+ import zope.generic.content
+ XMLConfig('meta.zcml', zope.generic.content)()
+
+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.face.testing.setUp(doctest)
+ zope.generic.configuration.testing.setUp(doctest)
+ zope.generic.operation.testing.setUp(doctest)
+ zope.generic.factory.testing.setUp(doctest)
+ zope.generic.adapter.testing.setUp(doctest)
+ zope.generic.handler.testing.setUp(doctest)
+ # internal setup
+ setUp(doctest)
+
+ def tearDown(self, doctest=None):
+ # internal teardown
+ tearDown(doctest)
+ # external teardown
+ zope.generic.handler.testing.tearDown(doctest)
+ zope.generic.adapter.testing.tearDown(doctest)
+ zope.generic.factory.testing.tearDown(doctest)
+ zope.generic.operation.testing.tearDown(doctest)
+ zope.generic.configuration.testing.tearDown(doctest)
+ zope.generic.face.testing.tearDown(doctest)
+ zope.generic.directlyprovides.testing.tearDown(doctest)
+ zope.generic.testing.testing.tearDown(doctest)
+ super(PlacelessSetup, self).tearDown()
+
+placelesssetup = PlacelessSetup()
Property changes on: zope.generic/trunk/src/zope/generic/content/testing.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/tests.py
===================================================================
--- zope.generic/trunk/src/zope/generic/content/tests.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/tests.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,53 @@
+##############################################################################
+#
+# 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 import schema
+from zope.testing import doctest
+
+
+from zope.generic.content import api
+from zope.generic.content import testing
+from zope.generic.testing.testing import registerDirective
+
+
+
+def test_suite():
+ return unittest.TestSuite((
+ 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('EXAMPLE.txt',
+ setUp=testing.placelesssetup.setUp,
+ tearDown=testing.placelesssetup.tearDown,
+ globs={'component': component, 'interface': interface,
+ 'schema': schema, '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/content/tests.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/zope.generic.content-configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/content/zope.generic.content-configure.zcml 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/zope.generic.content-configure.zcml 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+ <include package="zope.generic.content" />
+
+</configure>
Property changes on: zope.generic/trunk/src/zope/generic/content/zope.generic.content-configure.zcml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/content/zope.generic.content-meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/content/zope.generic.content-meta.zcml 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/content/zope.generic.content-meta.zcml 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+ <include package="zope.generic.content" file="meta.zcml" />
+
+</configure>
Property changes on: zope.generic/trunk/src/zope/generic/content/zope.generic.content-meta.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-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/directlyprovides/DEPENDENCIES.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -1,8 +1,9 @@
-zope.app.event
zope.app.testing
zope.component
zope.event
+zope.generic.directlyprovides
zope.generic.testing
zope.interface
+zope.lifecycleevent
zope.schema
zope.testing
\ No newline at end of file
Added: zope.generic/trunk/src/zope/generic/face/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/face/DEPENDENCIES.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/DEPENDENCIES.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,13 @@
+persistent
+zope.app.container
+zope.app.testing
+zope.component
+zope.configuration
+zope.dottedname
+zope.generic.directlyprovides
+zope.generic.face
+zope.generic.testing
+zope.interface
+zope.location
+zope.schema
+zope.testing
Property changes on: zope.generic/trunk/src/zope/generic/face/DEPENDENCIES.cfg
___________________________________________________________________
Name: svn:keywords
+ Id
Added: zope.generic/trunk/src/zope/generic/face/PUBLICATION.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/face/PUBLICATION.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/PUBLICATION.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,8 @@
+Metadata-Version: 1.0
+Name: zope.generic.face
+Summary: Provide key or context interfaces
+Author: Dominik Huber, Perse Engineering GmbH, Switzerland
+Author-email: dominik.huber at perse.ch
+License: ZPL 2.1
+Description:
+ n/a
Property changes on: zope.generic/trunk/src/zope/generic/face/PUBLICATION.cfg
___________________________________________________________________
Name: svn:keywords
+ Id
Added: zope.generic/trunk/src/zope/generic/face/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/face/README.txt 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/README.txt 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,251 @@
+============
+Generic Face
+============
+
+This package provides a mechanism to define and access key interface marker
+(IKeyfaceType) and a context interface marker (IConfaceType). Those interfaces
+can be used to provide dedicated information (IInformationProvider) such as
+configurations and annotations contextually.
+
+Within the system domain the key interface represents a permanent marker for an
+object. For example the marked object *is* a person. Regularly you will mark
+your content components with domain-specific key interface markers. Such a
+keyface (short for: key[ inter]face) has the same relation like classes
+to its instances.
+
+The context interface allows an more explicit comprehension and lookup of
+information related to objects. Contexts of understanding are often changing
+within the same system domain. Regularly a certain information provider is
+contextual. That means different information providers will provide the same
+type of information about one subject but the value of the provided information
+might differ contextually. For example your *name* within the system domain
+*world* is changing: Within your childs context it will be 'Dad', within your
+wife's context it will be 'Darling', within your friend's context it will be
+'Dude' and within the official context will be 'Mr. Foo Bar'.
+
+Both interface types provide the fundament to model more complex , contextual
+object-behavior and -properties. The package allows to define keys that allows
+a dedicated, but generic invocation of information providers. This allows
+dedicated facing or casing of objects.
+
+Context interface types
+-----------------------
+
+The context interface is one piece to lookup information providers contextually.
+You can provide a context interface simply by deriving from zope's Interface.
+
+ >>> class IMyContext(interface.Interface):
+ ... pass
+
+The context interface should be registered by the conface directive. This
+asserts that the interface get marked as IKeyfaceType:
+
+ >>> api.IKeyfaceType.providedBy(IMyContext)
+ False
+
+ >>> registerDirective('''
+ ... <generic:face
+ ... conface="example.IMyContext"
+ ... />
+ ... ''')
+
+ >>> api.IConfaceType.providedBy(IMyContext)
+ True
+
+As usual the typed interface is registered as utility too:
+
+ >>> component.getUtility(api.IConfaceType,
+ ... api.toDottedName(IMyContext)) == IMyContext
+ True
+
+As usual you can type context interfaces with other interface types:
+
+ >>> class IMyType(interface.interfaces.IInterface):
+ ... pass
+
+ >>> registerDirective('''
+ ... <generic:face
+ ... conface="example.IMyContext"
+ ... type="example.IMyType"
+ ... />
+ ... ''')
+
+ >>> IMyType.providedBy(IMyContext)
+ True
+ >>> component.getUtility(IMyType,
+ ... api.toDottedName(IMyContext)) == IMyContext
+ True
+
+Key interface types
+-------------------
+
+The behavior of components within the ca-framework depends heavily on their
+provided interfaces. A component, except most of the adapters and utilities,
+regularly provides more than one interface. The adaption and subscriber
+mechanism of the ca-framework invokes the provided interfaces by a
+lookup-algorithmus similar to the method resolution order by class inherintance.
+
+Most of the time this behavior satisfies our requirements. Additionally this
+package offers a mechanism to declare a single key interface (IFace).
+This key interface can be used to lookup corresponding information providers
+more explicitly.
+
+First we use a key interface:
+
+ >>> class IFoo(interface.Interface):
+ ... pass
+
+The key interface should be registered by the keyface directive. This asserts
+that the interface get marked as IKeyfaceType:
+
+ >>> api.IKeyfaceType.providedBy(IFoo)
+ False
+
+ >>> registerDirective('''
+ ... <generic:face
+ ... keyface="example.IFoo"
+ ... />
+ ... ''')
+
+ >>> api.IKeyfaceType.providedBy(IFoo)
+ True
+
+As usual the typed interface is registered as utility too:
+
+ >>> component.getUtility(api.IKeyfaceType,
+ ... api.toDottedName(IFoo)) == IFoo
+ True
+
+As usual you can type context interfaces with other interface types:
+
+ >>> registerDirective('''
+ ... <generic:face
+ ... keyface="example.IFoo"
+ ... type="example.IMyType"
+ ... />
+ ... ''')
+
+Afterward the interface will be typed regularly:
+
+ >>> IMyType.providedBy(IFoo)
+ True
+ >>> component.getUtility(IMyType,
+ ... api.toDottedName(IFoo)) == IFoo
+ True
+
+An exception of the directive in relation to the regular interface directive is,
+that you can mark key interfaces by a context interface. This marking says there
+might be contextual information. The abscence of a context marker asserts that
+there are *no* contextual informations to an key interface:
+
+ >>> registerDirective('''
+ ... <generic:face
+ ... keyface="example.IFoo"
+ ... type="example.IMyContext"
+ ... />
+ ... ''')
+
+ >>> IMyContext.providedBy(IFoo)
+ True
+
+Attention: Those contextual types will be not available as interface utility.
+Instead there will be an information provider
+(see zope.generic.informationprovider too):
+
+ >>> provider = component.getUtility(IMyContext,
+ ... api.toDottedName(IFoo))
+
+ >>> provider == IFoo
+ False
+
+ >>> IMyContext.providedBy(provider)
+ True
+
+ >>> IFoo.providedBy(provider)
+ True
+
+ >>> api.IInformationProvider.providedBy(provider)
+ True
+
+
+How to provide the face mechanism
+---------------------------------
+
+The IFaced interface promises access to keyface and/or conface of an object.
+The lookup of key and context interfaces is regularly done by providing
+IAttributeFaced.
+
+Then we have to decorate a corresponding key-faced component:
+
+ >>> class FooFaced(object):
+ ... interface.implements(api.IAttributeFaced)
+ ... __keyface__ = IFoo
+
+There is a default adapter to IFace for key-faced objects:
+
+ >>> foofaced = FooFaced()
+
+ >>> adapted = api.IFace(foofaced)
+ >>> adapted.keyface == IFoo
+ True
+ >>> adapted.conface == api.INoConface
+ True
+
+Furthermore there is simple Face mixin for AttributeFaced objects:
+
+ >>> class FooFace(api.Face):
+ ... __conface__ = IMyContext
+
+ >>> fooface = FooFace()
+ >>> fooface.keyface == api.INoKeyface
+ True
+ >>> fooface.conface == IMyContext
+ True
+
+The api provides convenience functions to get the key interfaces of components:
+
+ >>> api.getKeyface(foofaced) == IFoo
+ True
+
+ >>> api.getKeyface(fooface) == api.INoKeyface
+ True
+
+ >>> api.getKeyface(object())
+ Traceback (most recent call last):
+ ...
+ TypeError: ('Could not adapt', ...)
+
+ >>> api.queryKeyface(foofaced) == IFoo
+ True
+
+ >>> api.queryKeyface(fooface) == api.INoKeyface
+ True
+
+ >>> api.queryKeyface(object()) == None
+ True
+
+
+The api provides convenience functions to get the context interfaces of components:
+
+ >>> api.getConface(foofaced) == api.INoConface
+ True
+
+ >>> api.getConface(fooface) == IMyContext
+ True
+
+ >>> api.getConface(object())
+ Traceback (most recent call last):
+ ...
+ TypeError: ('Could not adapt', ...)
+
+ >>> api.queryConface(foofaced) == api.INoConface
+ True
+
+ >>> api.queryConface(fooface) == IMyContext
+ True
+
+ >>> api.queryConface(object()) == None
+ True
+
+
+
Property changes on: zope.generic/trunk/src/zope/generic/face/README.txt
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/SETUP.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/face/SETUP.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/SETUP.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,3 @@
+<data-files zopeskel/etc/package-includes>
+ zope.generic.face-*.zcml
+</data-files>
\ No newline at end of file
Property changes on: zope.generic/trunk/src/zope/generic/face/SETUP.cfg
___________________________________________________________________
Name: svn:keywords
+ Id
Added: zope.generic/trunk/src/zope/generic/face/__init__.py
===================================================================
--- zope.generic/trunk/src/zope/generic/face/__init__.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/__init__.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -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.face.interfaces import *
\ No newline at end of file
Property changes on: zope.generic/trunk/src/zope/generic/face/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/adapter.py
===================================================================
--- zope.generic/trunk/src/zope/generic/face/adapter.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/adapter.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,74 @@
+##############################################################################
+#
+# 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.component import adapts
+from zope.interface import implements
+from zope.location import Location
+
+from zope.generic.face import IAttributeFaced
+from zope.generic.face import IFace
+from zope.generic.face import INoConface
+from zope.generic.face import INoKeyface
+
+
+
+class FaceForAttributeFaced(Location):
+ """Adapts IAttributeFaced to IFace.
+
+ You can adapt IFace if you provide IAttributeFaced:
+
+ >>> fake_keyface = object()
+ >>> fake_conface = object()
+
+ >>> class AnyAttributeFaced(object):
+ ... __keyface__ = fake_keyface
+ ... __conface__ = fake_conface
+
+ >>> faced = AnyAttributeFaced()
+ >>> face = FaceForAttributeFaced(faced)
+ >>> face.keyface == fake_keyface
+ True
+ >>> face.conface == fake_conface
+ True
+
+ >>> class NoAttributeFaced(object):
+ ... pass
+
+ >>> faced = NoAttributeFaced()
+ >>> face = FaceForAttributeFaced(faced)
+ >>> face.keyface is INoKeyface
+ True
+ >>> face.conface is INoConface
+ True
+ """
+
+ implements(IFace)
+ adapts(IAttributeFaced)
+
+ def __init__(self, context):
+ self.context = context
+
+ @property
+ def keyface(self):
+ return getattr(self.context, '__keyface__', INoKeyface)
+
+ @property
+ def conface(self):
+ return getattr(self.context, '__conface__', INoConface)
Property changes on: zope.generic/trunk/src/zope/generic/face/adapter.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/face/api.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/api.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,81 @@
+##############################################################################
+#
+# 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.face import *
+from zope.generic.face.adapter import FaceForAttributeFaced
+from zope.generic.face.base import Face
+from zope.generic.face.base import KeyfaceDescription
+from zope.generic.face.helper import toDescription
+from zope.generic.face.helper import toDottedName
+from zope.generic.face.helper import toInterface
+from zope.generic.face.metaconfigure import ensureInformationProvider
+
+
+
+def getKeyface(object):
+ """Return the key interface from an object."""
+
+ # todo replace IInterface by IKeyfaceType
+ if IInterface.providedBy(object):
+ if not IKeyfaceType.providedBy(object):
+ #print object
+ pass
+
+ return object
+
+ if IAttributeFaced.providedBy(object):
+ return getattr(object, '__keyface__', INoKeyface)
+
+ return IFace(object).keyface
+
+
+
+def queryKeyface(object, default=None):
+ """Return the key interface from an object or default."""
+
+ try:
+ return getKeyface(object)
+
+ except:
+ return default
+
+
+
+def getConface(object):
+ """Return the context interface from an object."""
+
+ if IConfaceType.providedBy(object):
+ return object
+
+ if IAttributeFaced.providedBy(object):
+ return getattr(object, '__conface__', INoConface)
+
+ return IFace(object).conface
+
+
+
+def queryConface(object, default=None):
+ """Return the context interface from an object or default."""
+
+ try:
+ return getConface(object)
+
+ except:
+ return default
Property changes on: zope.generic/trunk/src/zope/generic/face/api.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/face/base.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/base.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,175 @@
+##############################################################################
+#
+# 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 zope.app.container.contained import Contained
+from zope.app.i18n import ZopeMessageFactory as _
+from zope.interface import implements
+
+from zope.generic.directlyprovides.api import provides
+from zope.generic.directlyprovides.api import updateDirectlyProvided
+from zope.generic.directlyprovides.api import UpdateProvides
+
+from zope.generic.face import IAttributeFaced
+from zope.generic.face import IFace
+from zope.generic.face import IGlobalInformationProvider
+from zope.generic.face import IKeyfaceDescription
+from zope.generic.face import ILocalInformationProvider
+from zope.generic.face import INoConface
+from zope.generic.face import INoKeyface
+
+
+
+class Face(object):
+ """Face interface mixin for key- and conface attribute implementations.
+
+ You can mixin this class if you like to provide IFace for
+ IAttributeFaced implementations:
+
+ >>> fake_keyface = object()
+ >>> fake_conface = object()
+
+ >>> class AnyAttributeFace(Face):
+ ... __keyface__ = fake_keyface
+ ... __conface__ = fake_conface
+
+ >>> face = AnyAttributeFace()
+ >>> face.__keyface__ == fake_keyface
+ True
+ >>> face.__conface__ == fake_conface
+ True
+ >>> face.keyface == fake_keyface
+ True
+ >>> face.conface == fake_conface
+ True
+
+ >>> class NoAttributeFaced(Face):
+ ... pass
+
+ >>> face = NoAttributeFaced()
+ >>> face.__keyface__ is INoKeyface
+ Traceback (most recent call last):
+ ...
+ AttributeError: 'NoAttributeFaced' object has no attribute '__keyface__'
+ >>> face.__conface__ is INoConface
+ Traceback (most recent call last):
+ ...
+ AttributeError: 'NoAttributeFaced' object has no attribute '__conface__'
+ >>> face.keyface is INoKeyface
+ True
+ >>> face.conface is INoConface
+ True
+ """
+
+ implements(IFace)
+
+ @property
+ def keyface(self):
+ return getattr(self, '__keyface__', INoKeyface)
+
+ @property
+ def conface(self):
+ return getattr(self, '__conface__', INoConface)
+
+
+
+class GlobalInformationProvider(object):
+ """Global information provider."""
+
+ implements(IGlobalInformationProvider)
+
+ def __init__(self, __conface__=None, __keyface__=None):
+ directlyprovided = []
+ if __keyface__:
+ self.__keyface__ = __keyface__
+ directlyprovided.append(__keyface__)
+
+ if __conface__:
+ self.__conface__ = __conface__
+ directlyprovided.append(__conface__)
+
+ if directlyprovided:
+ updateDirectlyProvided(self, directlyprovided)
+
+ provides('__keyface__', '__conface__')
+
+ __keyface__ = UpdateProvides(IAttributeFaced['__keyface__'])
+ __conface__ = UpdateProvides(IAttributeFaced['__conface__'])
+
+ @property
+ def keyface(self):
+ return self.__keyface__
+
+ @property
+ def conface(self):
+ return self.__conface__
+
+
+
+class LocalInformationProvider(Contained, Persistent):
+ """Local information provider."""
+
+ implements(ILocalInformationProvider)
+
+ def __init__(self, __conface__=None, __keyface__=None):
+ directlyprovided = []
+ if __keyface__:
+ self.__keyface__ = __keyface__
+ directlyprovided.append(__keyface__)
+
+ if __conface__:
+ self.__conface__ = __conface__
+ directlyprovided.append(__conface__)
+
+ if directlyprovided:
+ updateDirectlyProvided(self, directlyprovided)
+
+ provides('__keyface__', '__conface__')
+
+ __keyface__ = UpdateProvides(IAttributeFaced['__keyface__'])
+ __conface__ = UpdateProvides(IAttributeFaced['__conface__'])
+
+ @property
+ def keyface(self):
+ return self.__keyface__
+
+ @property
+ def conface(self):
+ return self.__conface__
+
+
+
+class KeyfaceDescription(Face):
+ """Key interface description mixin."""
+
+ implements(IKeyfaceDescription)
+
+ def __init__(self, keyface, label=None, hint=None):
+ self.__keyface__ = keyface
+
+ if label is None:
+ self.label = _(keyface.__name__)
+ else:
+ self.label = label
+
+ if hint is None:
+ self.hint = _(keyface.__doc__)
+ else:
+ self.hint = hint
Property changes on: zope.generic/trunk/src/zope/generic/face/base.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/face/configure.zcml 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/configure.zcml 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,43 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:apidoc="http://namespaces.zope.org/apidoc"
+ xmlns:generic="http://namespaces.zope.org/generic"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ i18n_domain="zope">
+
+ <apidoc:bookchapter zcml:condition="have apidoc"
+ id="zope.generic.face.readme"
+ title="Face"
+ doc_path="README.txt"
+ parent="zope.generic"
+ />
+
+ <!-- attribute configurations -->
+ <class class=".adapter.FaceForAttributeFaced">
+ <require
+ permission="zope.Public"
+ interface=".IFace"
+ />
+ </class>
+
+ <adapter
+ factory=".adapter.FaceForAttributeFaced"
+ provides=".IFace"
+ trusted="True"
+ />
+
+ <class class=".base.GlobalInformationProvider">
+ <require
+ permission="zope.Public"
+ interface=".IFace"
+ />
+ </class>
+
+ <class class=".base.LocalInformationProvider">
+ <require
+ permission="zope.Public"
+ interface=".IFace"
+ />
+ </class>
+
+</configure>
Property changes on: zope.generic/trunk/src/zope/generic/face/configure.zcml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/helper.py
===================================================================
--- zope.generic/trunk/src/zope/generic/face/helper.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/helper.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,132 @@
+##############################################################################
+#
+# 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 toInterface(dottedname):
+ try:
+ return __name_to_component[dottedname]
+ except KeyError:
+ return __name_to_component.setdefault(dottedname, resolve(dottedname))
+
+
+def toDescription(component, label=None, hint=None):
+ """Use the __doc__ attribute for label and hint.
+
+ This function can be used to generate the label an hint of an description.
+
+ No doc string provided:
+
+ >>> class A:
+ ... pass
+
+ >>> label, hint = toDescription(A)
+ >>> label
+ u''
+ >>> hint
+ u''
+
+ Single line:
+
+ >>> class B:
+ ... '''Test label.
+ ... '''
+
+ >>> label, hint = toDescription(B)
+ >>> label
+ u'Test label.'
+ >>> hint
+ u''
+
+ Multi line:
+
+ >>> class C:
+ ... '''Test label.
+ ...
+ ... Test hint, bla bla .
+ ... bla bla bla:
+ ... - bla, bla, bla. '''
+
+ >>> label, hint = toDescription(C)
+ >>> label
+ u'Test label.'
+ >>> hint
+ u'Test hint, bla bla .\\\\nbla bla bla:\\\\n- bla, bla, bla.'
+
+ You can overwrite the underlying doc string providing your own
+ label or hint:
+
+ >>> label, hint = toDescription(C, label=u'My label')
+ >>> label
+ u'My label'
+ >>> hint
+ u'Test hint, bla bla .\\\\nbla bla bla:\\\\n- bla, bla, bla.'
+
+ >>> label, hint = toDescription(C, hint=u'My hint')
+ >>> label
+ u'Test label.'
+ >>> hint
+ u'My hint'
+
+ """
+ if label and hint:
+ return (label, hint)
+
+ elif label:
+ doc = getattr(component, '__doc__', None)
+ if doc:
+ lines = doc.splitlines()
+ if lines and lines > 2:
+ return (label, u'\\n'.join([line.strip() for line in lines[2:]]))
+
+ return (label, u'')
+
+ elif hint:
+ doc = getattr(component, '__doc__', None)
+ if doc:
+ lines = doc.splitlines()
+ if lines:
+ return (unicode(lines[0].strip()), hint)
+
+ return (u'')
+
+ else:
+ doc = getattr(component, '__doc__', None)
+ if doc:
+ lines = doc.splitlines()
+ if lines:
+ if lines > 2:
+ return (unicode(lines[0].strip()), u'\\n'.join([line.strip() for line in lines[2:]]))
+
+ else:
+ return (unicode(lines[0].strip()), u'')
+
+ return (u'', u'')
Property changes on: zope.generic/trunk/src/zope/generic/face/helper.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/face/interfaces.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/interfaces.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,153 @@
+##############################################################################
+#
+# 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.interface import Interface
+from zope.interface.interfaces import IInterface
+from zope.schema import Object
+from zope.schema import Text
+from zope.schema import TextLine
+
+from zope.generic.directlyprovides import IProvides
+
+
+class IKeyfaceType(IInterface):
+ """Mark key interfaces.
+
+ The key interface is the most relevant interface of the object in relation
+ to a system domain."""
+
+
+
+class INoKeyface(Interface):
+ """A unspecified key interface."""
+
+alsoProvides(INoKeyface, IKeyfaceType)
+
+
+
+class IConfaceType(IInterface):
+ """Mark context interfaces.
+
+ The context interface declares the context wherein infomration about an
+ object should be catched."""
+
+
+
+class INoConface(Interface):
+ """A unspecified context interface."""
+
+alsoProvides(INoConface, IConfaceType)
+
+
+
+class IFaced(Interface):
+ """Assert that the key interface can be looked up.
+
+ The key interface must be provided by adaption to IFace."""
+
+
+
+class IFace(IFaced):
+ """Declare the relevant key and context interface."""
+
+ keyface = Object(
+ title=_('Key interface'),
+ description=_('Key interface of the underlying object.'),
+ readonly=True,
+ default=INoKeyface,
+ schema=IKeyfaceType)
+
+ conface = Object(
+ title=_('Context interface'),
+ description=_('Context interface of the underlying object.'),
+ readonly=True,
+ default=INoConface,
+ schema=IConfaceType)
+
+
+
+class IAttributeFaced(IFaced):
+ """Store the key and context interface within an attribute.
+
+ The context interface is provided by the attribute __conface__.
+ The key interface is provided by the attribute __keyface__.
+
+ If no attribute is defined INoConface or INoKeyface will be returned.
+ """
+
+ __keyface__ = Object(
+ title=_('Key interface'),
+ description=_('Key interface of the assoziated object.'),
+ readonly=True,
+ default=INoKeyface,
+ schema=IKeyfaceType)
+
+ __conface__ = Object(
+ title=_('Context interface'),
+ description=_('Context interface of the assoziated object.'),
+ readonly=True,
+ default=INoConface,
+ schema=IConfaceType)
+
+
+
+class IProvidesAttributeFaced(IAttributeFaced, IProvides):
+ """Directly provide the key and context interface."""
+
+
+class IKeyfaceDescription(Interface):
+ """Describe an key interface."""
+
+ label = TextLine(title=_('Lable'))
+
+ hint = Text(title=_('Hint'))
+
+
+
+class IInformationProvider(IProvidesAttributeFaced):
+ """Provide information to a dedicated context and key interface pair.
+
+ Information provider will be registered as utility providing the context
+ interface and named by the dotted name of the key interface.
+
+ Information providers can be extended by generic information mechanism
+ such as zope.annotation.IAnnotations simply by adding a specific marker to
+ the information provider implementation. The marker should invoke the
+ specific information mechanism:
+
+ classProvides(api.InformationProvider, IAttributeAnnotatable)
+
+ <class class="zope.generic.api.InformationProvider" >
+ <implements="zope.annotation.IAttributeAnnotatable" />
+ </class>
+ """
+
+
+class IGlobalInformationProvider(IInformationProvider):
+ """Global information provider."""
+
+
+class ILocalInformationProvider(IInformationProvider):
+ """Local information provider."""
+
+
+
Property changes on: zope.generic/trunk/src/zope/generic/face/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/face/meta.zcml 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/meta.zcml 2006-04-30 22:47:53 UTC (rev 67773)
@@ -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="face"
+ schema=".metadirectives.IFaceDirective"
+ handler=".metaconfigure.faceDirective"
+ />
+
+ </meta:directives>
+
+</configure>
Property changes on: zope.generic/trunk/src/zope/generic/face/meta.zcml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/face/metaconfigure.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/metaconfigure.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,112 @@
+##############################################################################
+#
+# 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.component import provideUtility
+from zope.component import queryUtility
+from zope.component.interface import provideInterface
+from zope.configuration.exceptions import ConfigurationError
+from zope.interface import alsoProvides
+
+from zope.generic.face import IConfaceType
+from zope.generic.face import IKeyfaceType
+from zope.generic.face import INoKeyface
+from zope.generic.face.base import GlobalInformationProvider
+from zope.generic.face.base import LocalInformationProvider
+from zope.generic.face.helper import toDottedName
+
+
+def ensureInformationProvider(conface, keyface, context=None):
+ """Provide an information provider."""
+
+ # preconditions
+ if not IConfaceType.providedBy(conface):
+ raise TypeError('Conface requires %.' % IConfaceType.__name__)
+
+ if not IKeyfaceType.providedBy(keyface):
+ raise TypeError('Keyface requires %.' % IKeyfaceType.__name__)
+
+ # essentials
+ name = toDottedName(keyface)
+
+ provider = queryUtility(conface, name, context=context)
+
+ if not provider:
+
+ if context is None:
+ provider = GlobalInformationProvider(conface, keyface)
+ provideUtility(provider, conface, name=name)
+
+ else:
+ provider = LocalInformationProvider(conface, keyface)
+ context.registerUtility(provider, conface, name=name)
+
+
+
+def keyfaceDirective(_context, keyface, type=None):
+ """Type and register an new key interface."""
+
+ # context can never be key interface and key can never be context interface
+ if keyface and IConfaceType.providedBy(keyface):
+ raise ConfigurationError('Key interface %s can not be registered as context interface too.' % keyface.__name__)
+
+ # provide type as soon as possilbe
+ provideInterface(None, keyface, IKeyfaceType)
+
+ if type:
+ # provide additional interface utility
+ if not IConfaceType.providedBy(type):
+ provideInterface(None, keyface, type)
+
+ # provide global information provider
+ else:
+ alsoProvides(keyface, type)
+ ensureInformationProvider(type, keyface)
+
+
+
+def confaceDirective(_context, conface, type=None):
+ """Type and register an new context interface."""
+
+ # context can never be key interface and key can never be context interface
+ if conface and IKeyfaceType.providedBy(conface):
+ raise ConfigurationError('Context interface %s can not be registered as key interface too.' % conface.__name__)
+
+ # provide type as soon as possilbe
+ provideInterface(None, conface, IConfaceType)
+
+ # provide additional interface utility
+ if type:
+ provideInterface(None, conface, type)
+
+
+
+def faceDirective(_context, keyface=None, conface=None, type=None):
+ """Type and register an new key or context interface."""
+
+ # preconditions
+ # register only key or context interface
+ if keyface and conface:
+ raise ConfigurationError('Cannot register a key or a context interface at the same time.')
+
+ if keyface:
+ keyfaceDirective(_context, keyface, type)
+
+ else:
+ confaceDirective(_context, conface, type)
Property changes on: zope.generic/trunk/src/zope/generic/face/metaconfigure.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/face/metadirectives.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/metadirectives.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,56 @@
+##############################################################################
+#
+# 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):
+ """Key interface registration directive."""
+
+ keyface = GlobalInterface(
+ title=_('Key Interface'),
+ description=_('Interface that represents an information key.'),
+ required=False
+ )
+
+
+
+class IConfaceDirective(Interface):
+ """Context interface registration directive."""
+
+ conface = GlobalInterface(
+ title=_('Context Interface'),
+ description=_('Interface that represents an information context.'),
+ required=False
+ )
+
+
+
+class IFaceDirective(IKeyfaceDirective, IConfaceDirective):
+ """Key or context interface registration directive."""
+
+ type = GlobalInterface(
+ title=_('Type'),
+ description=_('Type a key or contex interface by a regular type or type '
+ 'an key interface and interfac providing IConfaceType.'),
+ required=False
+ )
Property changes on: zope.generic/trunk/src/zope/generic/face/metadirectives.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/face/testing.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/testing.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -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
+import zope.generic.directlyprovides.testing
+import zope.generic.face.testing
+import zope.generic.testing.testing
+
+from zope.component import provideAdapter
+from zope.configuration.xmlconfig import XMLConfig
+from zope.interface import alsoProvides
+from zope.interface import Interface
+
+from zope.generic.face import IConfaceType
+from zope.generic.face import IKeyfaceType
+
+
+
+
+################################################################################
+#
+# Public Test implementations
+#
+################################################################################
+
+class IFoo(Interface):
+ """Test key interface."""
+
+alsoProvides(IFoo, IKeyfaceType)
+
+
+
+class ITestContext(Interface):
+ """Test context interface."""
+
+
+alsoProvides(ITestContext, IConfaceType)
+
+
+class TestAttributeFaced(object):
+ __keyface__ = IFoo
+ __conface__ = ITestContext
+
+
+
+################################################################################
+#
+# Placeless setup
+#
+################################################################################
+
+# specific tests
+def setUp(doctest=None):
+ # register default keyface adapter
+ import zope.generic.face.adapter
+ from zope.generic.face import IFace
+ provideAdapter(zope.generic.face.adapter.FaceForAttributeFaced ,
+ provides=IFace)
+
+ # register the directive of this package
+ import zope.generic.face
+ XMLConfig('meta.zcml', zope.generic.face)()
+
+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.face.testing.setUp(doctest)
+ # internal setup
+ setUp(doctest)
+
+ def tearDown(self, doctest=None):
+ super(PlacelessSetup, self).tearDown()
+ # external teardown
+ zope.generic.face.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/face/testing.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/tests.py
===================================================================
--- zope.generic/trunk/src/zope/generic/face/tests.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/tests.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,76 @@
+##############################################################################
+#
+# 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.face import api
+from zope.generic.face import testing
+
+
+###############################################################################
+#
+# Unit tests
+#
+###############################################################################
+
+
+class FaceAdapterTest(InterfaceBaseTest):
+
+ _verify_class = False
+
+ @property
+ def _test_interface(self):
+ from zope.generic.face import IFace
+ return IFace
+
+ @property
+ def _test_class(self):
+ from zope.generic.face.adapter import FaceForAttributeFaced
+ return FaceForAttributeFaced
+
+ @property
+ def _test_pos(self):
+ return (testing.TestAttributeFaced(),)
+
+
+def test_suite():
+ return unittest.TestSuite((
+ unittest.makeSuite(FaceAdapterTest),
+ doctest.DocTestSuite('zope.generic.face.adapter'),
+ doctest.DocTestSuite('zope.generic.face.base'),
+ doctest.DocTestSuite('zope.generic.face.helper'),
+ 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/face/tests.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/zope.generic.face-configure.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/face/zope.generic.face-configure.zcml 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/zope.generic.face-configure.zcml 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+ <include package="zope.generic.face" />
+
+</configure>
Property changes on: zope.generic/trunk/src/zope/generic/face/zope.generic.face-configure.zcml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zope.generic/trunk/src/zope/generic/face/zope.generic.face-meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/face/zope.generic.face-meta.zcml 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/face/zope.generic.face-meta.zcml 2006-04-30 22:47:53 UTC (rev 67773)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+ <include package="zope.generic.face" file="meta.zcml" />
+
+</configure>
Property changes on: zope.generic/trunk/src/zope/generic/face/zope.generic.face-meta.zcml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: zope.generic/trunk/src/zope/generic/factory/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/factory/DEPENDENCIES.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/factory/DEPENDENCIES.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -1,12 +1,16 @@
zope.app.component
-zope.app.event
zope.app.testing
zope.component
zope.configuration
zope.event
zope.generic.configuration
zope.generic.directlyprovides
+zope.generic.face
+zope.generic.factory
zope.generic.informationprovider
-zope.generic.keyface
zope.generic.operation
-zope.generic.testing
\ No newline at end of file
+zope.generic.testing
+zope.interface
+zope.lifecycleevent
+zope.security
+zope.testing
\ No newline at end of file
Modified: zope.generic/trunk/src/zope/generic/factory/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/factory/README.txt 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/factory/README.txt 2006-04-30 22:47:53 UTC (rev 67773)
@@ -26,7 +26,7 @@
... pass
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IMyInstance"
... />
... ''')
@@ -35,15 +35,15 @@
parameters:
>>> from zope.generic.configuration import IAttributeConfigurable
- >>> from zope.generic.keyface import IAttributeKeyfaced
+ >>> from zope.generic.face import IAttributeFaced
>>> class Example(object):
- ... interface.implements(IAttributeKeyfaced, IAttributeConfigurable)
+ ... interface.implements(IAttributeFaced, IAttributeConfigurable)
... def __init__(self, a, b, c):
... print '__init__:', 'a=',a ,', b=', b, ', c=', c
Now we have to declare the signature for our key interface. We like to provide
-default arguments. Afterward we register the schema as IConfigurationType:
+default arguments. Afterward we register the schema as IConfiguration:
>>> from zope.schema import TextLine
@@ -53,9 +53,9 @@
... c = TextLine(required=False, default=u'c default')
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IMyParameter"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
@@ -74,7 +74,7 @@
... class="example.Example"
... operations="example.init_handler"
... input="example.IMyParameter"
- ... providesKeyface="True"
+ ... providesFace="True"
... storeInput="True"
... notifyCreated="True"
... />
@@ -83,15 +83,15 @@
The keyface defines the key interface to lookup the factory. The class
is the implementation. The operations attribute defines one operation or a
pipe of operations (see zope.generic.operation). Input declares the input
-parameter. The attribute provideKeyface asserts that the key interface is
+parameter. The attribute provideFace asserts that the key interface is
provided. Four cases are checked:
1. If the class does provide the keyface nothing happens.
-2. If the instance provides zope.generic.keyface.IProvidesAttributeKeyfaced
+2. If the instance provides zope.generic.face.IProvidesAttributeFaced
the __keyface__ attribute is set and the updateDirectlyProvided is called.
-3. If zope.generic.keyface.IAttributeKeyfaced is provided the the __keyface__
+3. If zope.generic.face.IAttributeFaced is provided the the __keyface__
attribute is set and the keyface is directly provided.
4. Else only the keyface is directly provided.
@@ -106,11 +106,11 @@
>>> events = getEvents()
>>> len(events)
- 2
+ 4
>>> clearEvents()
>>> from zope.component import IFactory
- >>> from zope.generic.keyface.api import toDottedName
+ >>> from zope.generic.face.api import toDottedName
>>> util = component.getUtility(IFactory, name=toDottedName(IMyInstance))
>>> util.keyface == IMyInstance
Modified: zope.generic/trunk/src/zope/generic/factory/adapter.py
===================================================================
--- zope.generic/trunk/src/zope/generic/factory/adapter.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/factory/adapter.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -23,7 +23,7 @@
from zope.generic.informationprovider.api import queryInformation
from zope.generic.informationprovider.api import getInformationProvider
-from zope.generic.keyface import IKeyfaced
+from zope.generic.face import IFaced
from zope.generic.operation import IOperationConfiguration
from zope.generic.factory import IFactoryInformation
@@ -36,7 +36,7 @@
implements(IInitializer)
- adapts(IKeyfaced)
+ adapts(IFaced)
def __init__(self, context):
self.context = context
Modified: zope.generic/trunk/src/zope/generic/factory/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/factory/api.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/factory/api.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -22,7 +22,7 @@
from zope.generic.informationprovider.api import getInformationProvider
from zope.generic.informationprovider.api import queryInformation
-from zope.generic.keyface.api import toDottedName
+from zope.generic.face.api import toDottedName
from zope.generic.operation import IOperationConfiguration
from zope.generic.factory import *
Modified: zope.generic/trunk/src/zope/generic/factory/factory.py
===================================================================
--- zope.generic/trunk/src/zope/generic/factory/factory.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/factory/factory.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -29,16 +29,16 @@
from zope.generic.informationprovider.api import getInformationProvider
from zope.generic.informationprovider.api import provideInformation
from zope.generic.informationprovider.api import queryInformation
-from zope.generic.keyface import IAttributeKeyfaced
-from zope.generic.keyface import IProvidesAttributeKeyfaced
-from zope.generic.keyface.api import Keyface
+from zope.generic.face import IAttributeFaced
+from zope.generic.face import IProvidesAttributeFaced
+from zope.generic.face.api import Face
from zope.generic.operation import IOperationConfiguration
from zope.generic.factory import IFactoryInformation
-class Factory(factory.Factory, Keyface):
+class Factory(factory.Factory, Face):
"""Key-interface-based factory implementation.
First we declare an key interface:
@@ -72,19 +72,19 @@
We can provide the key interface during the creation:
- >>> f = Factory(Simple, IMyInstance, providesKeyface=True)
+ >>> f = Factory(Simple, IMyInstance, providesFace=True)
>>> IMyInstance.providedBy(f())
True
- If the class does implement IAttributeKeyfaced the __keyface__
+ If the class does implement IAttributeFaced the __keyface__
attribute is set too:
- >>> from zope.generic.keyface import IAttributeKeyfaced
+ >>> from zope.generic.face import IAttributeFaced
>>> class SimpleKeyFaced(object):
- ... interface.implements(IAttributeKeyfaced)
+ ... interface.implements(IAttributeFaced)
- >>> f = Factory(SimpleKeyFaced, IMyInstance, providesKeyface=True)
+ >>> f = Factory(SimpleKeyFaced, IMyInstance, providesFace=True)
>>> IMyInstance.providedBy(f())
True
>>> f().__keyface__ is IMyInstance
@@ -145,7 +145,7 @@
>>> from zope.schema import TextLine
>>> class SimpleKeyFacedWithParameter(object):
- ... interface.implements(IAttributeKeyfaced)
+ ... interface.implements(IAttributeFaced)
... def __init__(self, a, b, c):
... print '__init__:', 'a=',a ,', b=', b, ', c=', c
@@ -155,9 +155,9 @@
... c = TextLine(required=False, default=u'c default')
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IMyParameter"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
@@ -198,7 +198,7 @@
>>> from zope.generic.configuration import IAttributeConfigurable
>>> class SimpleConfigurable(object):
- ... interface.implements(IAttributeKeyfaced, IAttributeConfigurable)
+ ... interface.implements(IAttributeFaced, IAttributeConfigurable)
... def __init__(self, a, b, c):
... print '__init__:', 'a=',a ,', b=', b, ', c=', c
@@ -215,7 +215,7 @@
"""
- def __init__(self, callable, __keyface__, providesKeyface=False,
+ def __init__(self, callable, __keyface__, providesFace=False,
storeInput=False, notifyCreated=False,
title=u'', description=u'', mode=0):
@@ -223,7 +223,7 @@
# essentials
self.__keyface__ = __keyface__
- self.__provideKeyface = providesKeyface
+ self.__provideFace = providesFace
self.__storeInput = storeInput
self.__notifyCreated = notifyCreated
self.__mode = mode
@@ -246,13 +246,13 @@
# provide key interface
- if self.__provideKeyface:
+ if self.__provideFace:
if not self.keyface.providedBy(instance):
- if IProvidesAttributeKeyfaced.providedBy(instance):
+ if IProvidesAttributeFaced.providedBy(instance):
instance.__dict__['__keyface__'] = self.keyface
updateDirectlyProvided(instance, self.keyface)
- elif IAttributeKeyfaced.providedBy(instance):
+ elif IAttributeFaced.providedBy(instance):
instance.__dict__['__keyface__'] = self.keyface
alsoProvides(instance, self.keyface)
Modified: zope.generic/trunk/src/zope/generic/factory/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/factory/metaconfigure.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/factory/metaconfigure.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -31,10 +31,10 @@
from zope.generic.informationprovider.api import provideInformation
from zope.generic.informationprovider.metaconfigure import InformationProviderDirective
from zope.generic.informationprovider.metaconfigure import provideInformationProvider
-from zope.generic.keyface import IKeyfaceType
-from zope.generic.keyface.api import toDescription
-from zope.generic.keyface.api import toDottedName
-from zope.generic.keyface.metaconfigure import keyfaceDirective
+from zope.generic.face import IKeyfaceType
+from zope.generic.face.api import toDescription
+from zope.generic.face.api import toDottedName
+from zope.generic.face.metaconfigure import keyfaceDirective
from zope.generic.operation.api import assertOperation
from zope.generic.operation.api import provideOperationConfiguration
@@ -44,7 +44,7 @@
def factoryDirective(_context, keyface, class_, type=None, operations=(), input=None,
- providesKeyface=False, notifyCreated=False, storeInput=False,
+ providesFace=False, notifyCreated=False, storeInput=False,
label=None, hint=None):
"""Register a public factory."""
# preconditions
@@ -73,11 +73,11 @@
else:
mode = 0
- if mode and providesKeyface:
+ if mode and providesFace:
output = keyface
# create and proxy type factory
- factory = Factory(class_, keyface, providesKeyface, storeInput,
+ factory = Factory(class_, keyface, providesFace, storeInput,
notifyCreated, label, hint, mode)
component = proxify(factory, InterfaceChecker(IFactory, CheckerPublic))
Modified: zope.generic/trunk/src/zope/generic/factory/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/factory/metadirectives.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/factory/metadirectives.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -36,8 +36,8 @@
required=True
)
- providesKeyface = Bool(
- title=_('Provides Keyface'),
+ providesFace = Bool(
+ title=_('Provides Face'),
description=_('If the class does not implement the key interface ' +
'directly provide it to the instances ' +
'before initalization.'),
Modified: zope.generic/trunk/src/zope/generic/factory/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/factory/testing.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/factory/testing.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -22,7 +22,7 @@
import zope.generic.configuration.testing
import zope.generic.directlyprovides.testing
import zope.generic.informationprovider.testing
-import zope.generic.keyface.testing
+import zope.generic.face.testing
import zope.generic.operation.testing
import zope.generic.testing.testing
@@ -61,7 +61,7 @@
# external setup
zope.generic.testing.testing.setUp(doctest)
zope.generic.directlyprovides.testing.setUp(doctest)
- zope.generic.keyface.testing.setUp(doctest)
+ zope.generic.face.testing.setUp(doctest)
zope.generic.configuration.testing.setUp(doctest)
zope.generic.informationprovider.testing.setUp(doctest)
zope.generic.operation.testing.setUp(doctest)
@@ -75,7 +75,7 @@
zope.generic.operation.testing.tearDown(doctest)
zope.generic.informationprovider.testing.tearDown(doctest)
zope.generic.configuration.testing.tearDown(doctest)
- zope.generic.keyface.testing.tearDown(doctest)
+ zope.generic.face.testing.tearDown(doctest)
zope.generic.directlyprovides.testing.tearDown(doctest)
zope.generic.testing.testing.tearDown(doctest)
super(PlacelessSetup, self).tearDown()
Modified: zope.generic/trunk/src/zope/generic/handler/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/handler/DEPENDENCIES.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/handler/DEPENDENCIES.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -1,13 +1,11 @@
-zope.app.component
-zope.location
-zope.app.security
zope.app.testing
zope.component
zope.configuration
zope.generic.configuration
zope.generic.directlyprovides
-zope.generic.keyface
+zope.generic.face
+zope.generic.handler
+zope.generic.operation
zope.generic.testing
zope.interface
-zope.schema
zope.testing
\ No newline at end of file
Modified: zope.generic/trunk/src/zope/generic/handler/PUBLICATION.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/handler/PUBLICATION.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/handler/PUBLICATION.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -5,6 +5,6 @@
Author-email: dominik.huber at perse.ch
License: ZPL 2.1
Description:
- This package offers a mechanism to declare a key interface (IKeyface).
+ This package offers a mechanism to declare a key interface (IFace).
The key interface can be used to lookup corresponding information providers
explicitly.
Modified: zope.generic/trunk/src/zope/generic/handler/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/handler/README.txt 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/handler/README.txt 2006-04-30 22:47:53 UTC (rev 67773)
@@ -15,7 +15,7 @@
... """The key interface."""
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IFoo"
... />
... ''')
Modified: zope.generic/trunk/src/zope/generic/handler/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/handler/metaconfigure.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/handler/metaconfigure.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -20,7 +20,7 @@
from zope.component.zcml import subscriber
-from zope.generic.keyface import IKeyfaceType
+from zope.generic.face import IKeyfaceType
from zope.generic.operation.api import assertOperation
Modified: zope.generic/trunk/src/zope/generic/handler/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/handler/metadirectives.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/handler/metadirectives.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -22,7 +22,7 @@
from zope.configuration.fields import GlobalInterface
from zope.interface import Interface
-from zope.generic.keyface.metadirectives import IBaseKeyfaceDirective
+from zope.generic.face.metadirectives import IKeyfaceDirective
from zope.generic.operation.metadirectives import IBaseOperationDirective
@@ -37,5 +37,5 @@
)
-class IHandlerDirective(IBaseKeyfaceDirective, IBaseHandlerDirective, IBaseOperationDirective):
+class IHandlerDirective(IKeyfaceDirective, IBaseHandlerDirective, IBaseOperationDirective):
"""Provide trusted locatable handler that invoke operations."""
Modified: zope.generic/trunk/src/zope/generic/handler/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/handler/testing.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/handler/testing.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -22,7 +22,7 @@
import zope.generic.configuration.testing
import zope.generic.directlyprovides.testing
import zope.generic.handler.testing
-import zope.generic.keyface.testing
+import zope.generic.face.testing
import zope.generic.testing.testing
from zope.configuration.xmlconfig import XMLConfig
@@ -60,7 +60,7 @@
# external setup
zope.generic.testing.testing.setUp(doctest)
zope.generic.directlyprovides.testing.setUp(doctest)
- zope.generic.keyface.testing.setUp(doctest)
+ zope.generic.face.testing.setUp(doctest)
zope.generic.configuration.testing.setUp(doctest)
zope.generic.handler.testing.setUp(doctest)
# internal setup
@@ -72,7 +72,7 @@
# external teardown
zope.generic.handler.testing.tearDown(doctest)
zope.generic.configuration.testing.tearDown(doctest)
- zope.generic.keyface.testing.tearDown(doctest)
+ zope.generic.face.testing.tearDown(doctest)
zope.generic.directlyprovides.testing.tearDown(doctest)
zope.generic.testing.testing.tearDown(doctest)
super(PlacelessSetup, self).tearDown()
Modified: zope.generic/trunk/src/zope/generic/informationprovider/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/DEPENDENCIES.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/informationprovider/DEPENDENCIES.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -1,3 +1,4 @@
+zope.annotation
zope.app.testing
zope.component
zope.configuration
@@ -3,7 +4,8 @@
zope.generic.configuration
zope.generic.directlyprovides
-zope.generic.keyface
+zope.generic.face
+zope.generic.informationprovider
zope.generic.testing
zope.interface
zope.schema
-zope.testing
\ No newline at end of file
+zope.testing
Modified: zope.generic/trunk/src/zope/generic/informationprovider/NEW_README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/NEW_README.txt 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/informationprovider/NEW_README.txt 2006-04-30 22:47:53 UTC (rev 67773)
@@ -43,9 +43,9 @@
This configuration should be registered by using the configuration directive:
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.ILogConfiguration"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
@@ -60,9 +60,9 @@
... sourceTag = BytesLine(title=u'Source Tag', required=False, default=' ')
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.ILoggerConfiguration"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
@@ -92,34 +92,34 @@
>>> from zope.interface import implements
>>> from zope.component import adapts
- >>> from zope.generic.keyface import IKeyface
+ >>> from zope.generic.face import IFace
>>> class Logger(object):
... """Generic logger adapter."""
... implements(ILogger)
- ... adapts(IKeyface)
+ ... adapts(IFace)
... def __init__(self, context):
... self.context = context
... def log(self, message):
- ... id = IKeyface(self.context())
+ ... id = IFace(self.context())
... info = queryInformationProvider(id.keyface, ILogUserInformation)
>>> class Logger(object):
... """Generic logger adapter."""
... implements(ILogger)
- ... adapts(IKeyface)
+ ... adapts(IFace)
... def __init__(self, context):
... self.context = context
... def log(self, message):
- ... id = IKeyface(self.context())
+ ... id = IFace(self.context())
... info = queryInformationProvider(id.keyface, ILogUserInformation)
>>> class Logger(object):
... """Generic logger adapter."""
... implements(ILogger)
- ... adapts(IKeyface)
+ ... adapts(IFace)
... def __init__(self, context):
... self.context = context
... def log(self, message):
- ... id = IKeyface(self.context())
+ ... id = IFace(self.context())
... info = queryInformationProvider(id.keyface, ILogUserInformation)
Modified: zope.generic/trunk/src/zope/generic/informationprovider/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/README.txt 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/informationprovider/README.txt 2006-04-30 22:47:53 UTC (rev 67773)
@@ -2,7 +2,7 @@
Generic Component
=================
-The key interface (see zope.generic.keyface) can be used to lookup corresponding
+The key interface (see zope.generic.face) can be used to lookup corresponding
information providers. This package offers a way to implement information
providers generically.
@@ -117,7 +117,7 @@
Information providers are configurable. The configurations mechanism is used
to provide additional configurations in a generic manner too. A configuration
-is declared by a configuration schema providing IConfigurationType:
+is declared by a configuration schema providing IConfiguration:
>>> from zope.schema import TextLine
@@ -125,15 +125,15 @@
... my = TextLine(title=u'My')
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IMyConfiguration"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
- >>> from zope.generic.configuration.api import IConfigurationType
+ >>> from zope.generic.configuration.api import IConfiguration
- >>> IConfigurationType.providedBy(IMyConfiguration)
+ >>> IConfiguration.providedBy(IMyConfiguration)
True
At the moment there are no configurations:
@@ -171,7 +171,7 @@
... ''')
>>> len(getEvents())
- 1
+ 3
>>> clearEvents()
>>> info = api.queryInformationProvider(IFooMarker, ISpecialInformation)
@@ -187,7 +187,7 @@
---------------
Configurations is a container of configuration data. Configuration data are
-defined by an schema which is providing IConfigurationType. The configuration
+defined by an schema which is providing IConfiguration. The configuration
data itself has to provide the schema that is used to reference it.
>>> from zope.schema import TextLine
@@ -196,9 +196,9 @@
... my = TextLine(title=u'My')
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IMyConfiguration"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
@@ -206,8 +206,8 @@
1
>>> clearEvents()
- >>> from zope.generic.configuration.api import IConfigurationType
- >>> IConfigurationType.providedBy(IMyConfiguration)
+ >>> from zope.generic.configuration.api import IConfiguration
+ >>> IConfiguration.providedBy(IMyConfiguration)
True
Regularly local configurations are provided by objects marked with
@@ -248,12 +248,12 @@
... 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):
+by IConfiguration (Regularly done by the configuration directive):
>>> from zope.interface import directlyProvides
- >>> directlyProvides(IFooConfiguration, IConfigurationType)
- >>> IConfigurationType.providedBy(IFooConfiguration)
+ >>> directlyProvides(IFooConfiguration, IConfiguration)
+ >>> IConfiguration.providedBy(IFooConfiguration)
True
The configurations provides a regular dictionary api by the UserDictMixin
@@ -273,7 +273,7 @@
[]
... if a value might be set to the configurations it must provide the
-configuration schema itself. This key interface must provide IConfigurationType:
+configuration schema itself. This key interface must provide IConfiguration:
>>> class IBarConfiguration(Interface):
... bar = TextLine(title=u'Bar')
@@ -281,7 +281,7 @@
>>> configurations[IBarConfiguration] = object()
Traceback (most recent call last):
...
- KeyError: 'Interface key IBarConfiguration does not provide IConfigurationType.'
+ KeyError: 'Interface key IBarConfiguration does not provide IConfiguration.'
>>> configurations[IFooConfiguration] = object()
Traceback (most recent call last):
Modified: zope.generic/trunk/src/zope/generic/informationprovider/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/api.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/informationprovider/api.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -21,13 +21,13 @@
from zope.annotation import IAnnotations
from zope.component import getUtilitiesFor
from zope.component import getUtility
-from zope.generic.keyface.api import getKeyface
-from zope.generic.keyface.api import queryKeyface
-from zope.generic.keyface.api import toDottedName
-from zope.generic.keyface.api import toKeyface
+from zope.generic.face.api import getKeyface
+from zope.generic.face.api import queryKeyface
+from zope.generic.face.api import toDottedName
+from zope.generic.face.api import toInterface
from zope.generic.configuration import IConfigurations
-from zope.generic.configuration import IConfigurationType
+from zope.generic.configuration import IConfiguration
from zope.generic.configuration.api import ConfigurationData
from zope.generic.informationprovider import *
@@ -56,13 +56,13 @@
"""Evaluate all information providers of a certain information aspect."""
for name, information in getUtilitiesFor(provider):
- yield (toKeyface(name), information)
+ yield (toInterface(name), information)
def getInformation(context, keyface):
"""Evaluate an information by a keyface (string or key keyface)."""
- if IConfigurationType.providedBy(keyface):
+ if IConfiguration.providedBy(keyface):
return keyface(IConfigurations(context))
else:
@@ -83,7 +83,7 @@
def provideInformation(context, keyface, information):
"""Set an information to a context using a keyface (string or key interface)."""
- if IConfigurationType.providedBy(keyface):
+ if IConfiguration.providedBy(keyface):
if type(information) is dict:
information = ConfigurationData(keyface, information)
@@ -97,7 +97,7 @@
def deleteInformation(context, keyface):
"""Delete an information of a context using a keyface (string or key interface)."""
- if IConfigurationType.providedBy(keyface):
+ if IConfiguration.providedBy(keyface):
del IConfigurations(context)[keyface]
else:
Modified: zope.generic/trunk/src/zope/generic/informationprovider/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/base.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/informationprovider/base.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -27,7 +27,7 @@
from zope.generic.configuration import IAttributeConfigurable
from zope.generic.configuration import IConfigurations
from zope.generic.configuration.api import AttributeConfigurations
-from zope.generic.keyface.api import KeyfaceDescription
+from zope.generic.face.api import KeyfaceDescription
from zope.generic.informationprovider import IInformationProvider
Modified: zope.generic/trunk/src/zope/generic/informationprovider/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/interfaces.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/informationprovider/interfaces.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -19,9 +19,10 @@
__docformat__ = 'restructuredtext'
from zope.interface import alsoProvides
+from zope.interface import Interface
-from zope.generic.keyface import IKeyfaceType
-from zope.generic.keyface import IKeyfaceDescription
+from zope.generic.face import IKeyfaceType
+from zope.generic.face import IKeyfaceDescription
@@ -37,7 +38,7 @@
-class IInformationProvider(IKeyfaceDescription):
+class IInformationProvider(Interface):
"""Provide information about a dedicated key interfaces.
A configuration related to the key interface can be stored within the
Modified: zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -25,8 +25,8 @@
from zope.interface import alsoProvides
from zope.generic.configuration import IConfigurations
-from zope.generic.keyface.api import toDescription
-from zope.generic.keyface.api import toDottedName
+from zope.generic.face.api import toDescription
+from zope.generic.face.api import toDottedName
from zope.generic.informationprovider.base import InformationProvider
from zope.generic.informationprovider import IInformationProvider
Modified: zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -26,11 +26,11 @@
from zope.schema import DottedName
from zope.generic.informationprovider import IInformationProvider
-from zope.generic.keyface.metadirectives import IBaseKeyfaceDirective
+from zope.generic.face.metadirectives import IKeyfaceDirective
-class IBaseInformationProviderDirective(IBaseKeyfaceDirective):
+class IBaseInformationProviderDirective(IKeyfaceDirective):
"""Base information provider attributes."""
label = MessageID(
Modified: zope.generic/trunk/src/zope/generic/informationprovider/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/testing.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/informationprovider/testing.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -21,7 +21,7 @@
import zope.app.testing.placelesssetup
import zope.generic.configuration.testing
import zope.generic.directlyprovides.testing
-import zope.generic.keyface.testing
+import zope.generic.face.testing
import zope.generic.testing.testing
from zope.configuration.xmlconfig import XMLConfig
@@ -62,7 +62,7 @@
# external setup
zope.generic.testing.testing.setUp(doctest)
zope.generic.directlyprovides.testing.setUp(doctest)
- zope.generic.keyface.testing.setUp(doctest)
+ zope.generic.face.testing.setUp(doctest)
zope.generic.configuration.testing.setUp(doctest)
# internal setup
setUp(doctest)
@@ -71,7 +71,7 @@
super(PlacelessSetup, self).tearDown()
# external teardown
zope.generic.configuration.testing.tearDown(doctest)
- zope.generic.keyface.testing.tearDown(doctest)
+ zope.generic.face.testing.tearDown(doctest)
zope.generic.directlyprovides.testing.tearDown(doctest)
zope.generic.testing.testing.tearDown(doctest)
# internal teardown
Modified: zope.generic/trunk/src/zope/generic/operation/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/DEPENDENCIES.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/operation/DEPENDENCIES.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -1,12 +1,12 @@
-zope.app.component
zope.app.testing
zope.component
zope.configuration
zope.generic.configuration
zope.generic.directlyprovides
+zope.generic.face
zope.generic.informationprovider
-zope.generic.keyface
+zope.generic.operation
zope.generic.testing
zope.interface
zope.schema
-zope.testing
\ No newline at end of file
+zope.testing
Modified: zope.generic/trunk/src/zope/generic/operation/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/README.txt 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/operation/README.txt 2006-04-30 22:47:53 UTC (rev 67773)
@@ -38,16 +38,16 @@
We have to register those parts:
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IAnyInput"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IAnyOutput"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
@@ -123,9 +123,9 @@
... print 'Pau input: a=%s.' % (input.a)
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IPAUConfig"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
@@ -161,9 +161,9 @@
... any = TextLine()
>>> registerDirective('''
- ... <generic:keyface
+ ... <generic:face
... keyface="example.IComplexConfig"
- ... type="zope.generic.configuration.IConfigurationType"
+ ... type="zope.generic.configuration.IConfiguration"
... />
... ''')
Modified: zope.generic/trunk/src/zope/generic/operation/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/base.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/operation/base.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -21,8 +21,8 @@
from zope.interface import implements
from zope.schema.fieldproperty import FieldProperty
-from zope.generic.keyface import IAttributeKeyfaced
-from zope.generic.keyface.api import Keyface
+from zope.generic.face import IAttributeFaced
+from zope.generic.face.api import Face
from zope.generic.configuration.api import parameterToConfiguration
from zope.generic.operation import IOperation
@@ -30,12 +30,12 @@
-class Operation(Keyface):
+class Operation(Face):
"""Generic operation wrapper."""
implements(IOperation)
- __keyface__ = FieldProperty(IAttributeKeyfaced['__keyface__'])
+ __keyface__ = FieldProperty(IAttributeFaced['__keyface__'])
def __init__(self, callable=None, keyface=None, input=None, output=None):
self._callable = callable
Modified: zope.generic/trunk/src/zope/generic/operation/interfaces.py
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/interfaces.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/operation/interfaces.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -25,11 +25,11 @@
from zope.schema import Object
from zope.schema import Tuple
-from zope.generic.configuration import IConfigurationType
+from zope.generic.configuration import IConfiguration
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.face import IFace
+from zope.generic.face import IKeyfaceType
@@ -47,7 +47,7 @@
-class IOperation(IKeyface):
+class IOperation(IFace):
"""Proceed operation"""
def __call__(context, *pos, **kws):
@@ -95,7 +95,7 @@
description=_('A configuration interface declaring the input parameters.'),
required=False,
default=(),
- value_type=Object(schema=IConfigurationType))
+ value_type=Object(schema=IConfiguration))
output = Tuple(title=_('Output Declaration'),
description=_('An interface interface declaring the output parameters.'),
@@ -105,4 +105,4 @@
-alsoProvides(IOperationConfiguration, IConfigurationType)
+alsoProvides(IOperationConfiguration, IConfiguration)
Modified: zope.generic/trunk/src/zope/generic/operation/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/metaconfigure.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/operation/metaconfigure.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -22,7 +22,7 @@
from zope.configuration.exceptions import ConfigurationError
from zope.interface import alsoProvides
-from zope.generic.configuration import IConfigurationType
+from zope.generic.configuration import IConfiguration
from zope.generic.configuration import IConfigurations
from zope.generic.configuration.api import ConfigurationData
from zope.generic.informationprovider.api import provideInformation
Modified: zope.generic/trunk/src/zope/generic/operation/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/operation/metadirectives.py 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/operation/metadirectives.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -24,7 +24,7 @@
from zope.configuration.fields import Tokens
from zope.interface import Interface
-from zope.generic.configuration import IConfigurationType
+from zope.generic.configuration import IConfiguration
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-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/operation/testing.py 2006-04-30 22:47:53 UTC (rev 67773)
@@ -24,7 +24,7 @@
import zope.generic.directlyprovides.testing
import zope.generic.configuration.testing
import zope.generic.informationprovider.testing
-import zope.generic.keyface.testing
+import zope.generic.face.testing
import zope.generic.operation
import zope.generic.testing.testing
@@ -66,7 +66,7 @@
# external setup
zope.generic.testing.testing.setUp(doctest)
zope.generic.directlyprovides.testing.setUp(doctest)
- zope.generic.keyface.testing.setUp(doctest)
+ zope.generic.face.testing.setUp(doctest)
zope.generic.configuration.testing.setUp(doctest)
zope.generic.informationprovider.testing.setUp(doctest)
# internal setup
@@ -77,7 +77,7 @@
# external teardown
zope.generic.informationprovider.testing.setUp(doctest)
zope.generic.configuration.testing.tearDown(doctest)
- zope.generic.keyface.testing.tearDown(doctest)
+ zope.generic.face.testing.tearDown(doctest)
zope.generic.directlyprovides.testing.tearDown(doctest)
zope.generic.testing.testing.tearDown(doctest)
Modified: zope.generic/trunk/src/zope/generic/testing/DEPENDENCIES.cfg
===================================================================
--- zope.generic/trunk/src/zope/generic/testing/DEPENDENCIES.cfg 2006-04-30 21:12:50 UTC (rev 67772)
+++ zope.generic/trunk/src/zope/generic/testing/DEPENDENCIES.cfg 2006-04-30 22:47:53 UTC (rev 67773)
@@ -4,4 +4,5 @@
zope.app.testing
zope.component
zope.configuration
-zope.interface
+zope.generic.testing
+zope.interface
\ No newline at end of file
More information about the Checkins
mailing list