[Checkins] SVN: zope.generic/trunk/src/zope/generic/
informationprovider directive:
Dominik Huber
dominik.huber at perse.ch
Tue Apr 25 01:31:46 EDT 2006
Log message for revision 67578:
informationprovider directive:
- merge configuration and annotation to information subdirective
Changed:
U zope.generic/trunk/src/zope/generic/informationprovider/README.txt
U zope.generic/trunk/src/zope/generic/informationprovider/meta.zcml
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/type/EXAMPLE.txt
U zope.generic/trunk/src/zope/generic/type/README.txt
U zope.generic/trunk/src/zope/generic/type/meta.zcml
-=-
Modified: zope.generic/trunk/src/zope/generic/informationprovider/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/README.txt 2006-04-24 18:58:07 UTC (rev 67577)
+++ zope.generic/trunk/src/zope/generic/informationprovider/README.txt 2006-04-25 05:31:44 UTC (rev 67578)
@@ -154,11 +154,11 @@
... registry="example.ISpecialInformation"
... label='Foo Specials' hint='Bla bla foo.'
... >
- ... <annotation
+ ... <information
... key="example.my_annotation"
... annotation="example.my_annotation"
... />
- ... <configuration
+ ... <information
... keyface="example.IMyConfiguration"
... configuration="example.my_configuration"
... />
Modified: zope.generic/trunk/src/zope/generic/informationprovider/meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/meta.zcml 2006-04-24 18:58:07 UTC (rev 67577)
+++ zope.generic/trunk/src/zope/generic/informationprovider/meta.zcml 2006-04-25 05:31:44 UTC (rev 67578)
@@ -11,15 +11,10 @@
>
<meta:subdirective
- name="configuration"
- schema=".metadirectives.IConfigurationSubdirective"
+ name="information"
+ schema=".metadirectives.IInformationSubdirective"
/>
- <meta:subdirective
- name="annotation"
- schema=".metadirectives.IAnnotationSubdirective"
- />
-
</meta:complexDirective>
</meta:directives>
Modified: zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py 2006-04-24 18:58:07 UTC (rev 67577)
+++ zope.generic/trunk/src/zope/generic/informationprovider/metaconfigure.py 2006-04-25 05:31:44 UTC (rev 67578)
@@ -134,25 +134,33 @@
"Handle empty/simple declaration."
return ()
- def configuration(self, _context, keyface, configuration):
+ def information(self, _context, keyface=None, configuration=None, key=None, annotation=None):
"""Add a configuration to the information provider."""
- # preconditions
- if not keyface.providedBy(configuration):
- raise ConfigurationError('Data attribute must provide %s.' % keyface.__name__)
+ # handle configuration
+ if keyface and configuration:
+ # preconditions
+ if not keyface.providedBy(configuration):
+ raise ConfigurationError('Data attribute must provide %s.' % keyface.__name__)
+
+ _context.action(
+ discriminator = (
+ 'informationprovider.configuration', self._keyface, self._registry, keyface),
+ callable = provideConfiguration,
+ args = (self._keyface, self._registry, keyface, configuration),
+ )
- _context.action(
- discriminator = (
- 'informationprovider.configuration', self._keyface, self._registry, keyface),
- callable = provideConfiguration,
- args = (self._keyface, self._registry, keyface, configuration),
- )
+ # handle annotation
+ elif key and annotation:
- def annotation(self, _context, key, annotation):
- """Add an annotation to the information provider."""
+ _context.action(
+ discriminator = (
+ 'informationprovider.annotation', self._keyface, self._registry, key),
+ callable = provideAnnotation,
+ args = (self._keyface, self._registry, key, annotation),
+ )
- _context.action(
- discriminator = (
- 'informationprovider.annotation', self._keyface, self._registry, key),
- callable = provideAnnotation,
- args = (self._keyface, self._registry, key, annotation),
- )
+ # handle wrong usage
+ else:
+ raise ConfigurationError('Information subdirective must provide ' +
+ 'key and annotation or keyface and configuration.')
+
\ No newline at end of file
Modified: zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py
===================================================================
--- zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py 2006-04-24 18:58:07 UTC (rev 67577)
+++ zope.generic/trunk/src/zope/generic/informationprovider/metadirectives.py 2006-04-25 05:31:44 UTC (rev 67578)
@@ -66,34 +66,29 @@
-class IConfigurationSubdirective(Interface):
- """Declare a certain configuration of a type."""
+class IInformationSubdirective(Interface):
+ """Declare a certain information of an information provider."""
keyface = GlobalInterface(
title=_('Interface'),
description=_('Interface referencing a configuraiton.'),
- required=True
+ required=False
)
configuration = GlobalObject(
title=_('Configuration'),
description=_('Configuration component providing the key interface.'),
- required=True
+ required=False
)
-
-
-class IAnnotationSubdirective(Interface):
- """Declare a certain configuration of a type."""
-
key = DottedName(
title=_('Interface'),
description=_('Interface referencing a configuraiton.'),
- required=True
+ required=False
)
annotation = GlobalObject(
title=_('Annotation'),
description=_('Annotation component expected undert the key.'),
- required=True
+ required=False
)
Modified: zope.generic/trunk/src/zope/generic/type/EXAMPLE.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/type/EXAMPLE.txt 2006-04-24 18:58:07 UTC (rev 67577)
+++ zope.generic/trunk/src/zope/generic/type/EXAMPLE.txt 2006-04-25 05:31:44 UTC (rev 67578)
@@ -115,7 +115,7 @@
... <initializer
... keyface='example.ITextConfig'
... />
- ... <configuration
+ ... <information
... keyface='example.ITextConfig'
... configuration='example.textDefaults'
... />
@@ -130,7 +130,7 @@
... <initializer
... keyface='example.INoteConfig'
... />
- ... <configuration
+ ... <information
... keyface='example.INoteConfig'
... configuration='example.noteDefaults'
... />
@@ -146,11 +146,11 @@
... keyface='example.IArticleInitializationConfiguration'
... handler="example.articleInitializer"
... />
- ... <configuration
+ ... <information
... keyface='example.ITextConfig'
... configuration='example.articleTextDefaults'
... />
- ... <configuration
+ ... <information
... keyface='example.INoteConfig'
... configuration='example.articleNoteDefaults'
... />
Modified: zope.generic/trunk/src/zope/generic/type/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/type/README.txt 2006-04-24 18:58:07 UTC (rev 67577)
+++ zope.generic/trunk/src/zope/generic/type/README.txt 2006-04-25 05:31:44 UTC (rev 67578)
@@ -162,7 +162,7 @@
... keyface='example.IOtherConfiguration'
... handler='example.barInitializer'
... />
- ... <configuration
+ ... <information
... keyface='example.IAnyConfiguration'
... configuration='example.typedata'
... />
Modified: zope.generic/trunk/src/zope/generic/type/meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/type/meta.zcml 2006-04-24 18:58:07 UTC (rev 67577)
+++ zope.generic/trunk/src/zope/generic/type/meta.zcml 2006-04-25 05:31:44 UTC (rev 67578)
@@ -11,8 +11,8 @@
>
<meta:subdirective
- name="configuration"
- schema="zope.generic.informationprovider.metadirectives.IConfigurationSubdirective"
+ name="information"
+ schema="zope.generic.informationprovider.metadirectives.IInformationSubdirective"
/>
<meta:subdirective
@@ -20,7 +20,6 @@
schema="zope.generic.type.metadirectives.IInitializerSubdirective"
/>
-
<meta:subdirective
name="configurationAdapter"
schema=".metadirectives.IConfigurationAdapterSubdirective"
More information about the Checkins
mailing list