[Checkins] SVN: zope.generic/trunk/src/zope/generic/content/ don't
dervie content directive form informationProvider directive
Dominik Huber
dominik.huber at perse.ch
Thu May 4 04:00:23 EDT 2006
Log message for revision 67960:
don't dervie content directive form informationProvider directive
Changed:
U zope.generic/trunk/src/zope/generic/content/EXAMPLE.txt
U zope.generic/trunk/src/zope/generic/content/README.txt
U zope.generic/trunk/src/zope/generic/content/meta.zcml
U zope.generic/trunk/src/zope/generic/content/metaconfigure.py
U zope.generic/trunk/src/zope/generic/content/testing.py
-=-
Modified: zope.generic/trunk/src/zope/generic/content/EXAMPLE.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/content/EXAMPLE.txt 2006-05-04 00:56:11 UTC (rev 67959)
+++ zope.generic/trunk/src/zope/generic/content/EXAMPLE.txt 2006-05-04 08:00:22 UTC (rev 67960)
@@ -125,6 +125,16 @@
>>> articleNoteDefaults = ConfigurationData(INoteConfig,
... {'body': u""})
+ >>> registerDirective('''
+ ... <generic:informationProvider
+ ... keyface="example.IText"
+ ... >
+ ... <information
+ ... keyface='example.ITextConfig'
+ ... configuration='example.textDefaults'
+ ... />
+ ... </generic:informationProvider>
+ ... ''')
>>> registerDirective('''
... <generic:content
@@ -133,12 +143,19 @@
... <factory
... class='zope.generic.content.api.Object'
... input='example.ITextConfig'
- ... />
+ ... />
+ ... </generic:content>
+ ... ''')
+
+ >>> registerDirective('''
+ ... <generic:informationProvider
+ ... keyface="example.INote"
+ ... >
... <information
- ... keyface='example.ITextConfig'
- ... configuration='example.textDefaults'
+ ... keyface='example.INoteConfig'
+ ... configuration='example.noteDefaults'
... />
- ... </generic:content>
+ ... </generic:informationProvider>
... ''')
>>> registerDirective('''
@@ -149,11 +166,22 @@
... class='zope.generic.content.api.Object'
... input='example.INoteConfig'
... />
+ ... </generic:content>
+ ... ''')
+
+ >>> registerDirective('''
+ ... <generic:informationProvider
+ ... keyface="example.IArticle"
+ ... >
... <information
+ ... keyface='example.ITextConfig'
+ ... configuration='example.articleTextDefaults'
+ ... />
+ ... <information
... keyface='example.INoteConfig'
- ... configuration='example.noteDefaults'
+ ... configuration='example.articleNoteDefaults'
... />
- ... </generic:content>
+ ... </generic:informationProvider>
... ''')
>>> registerDirective('''
@@ -166,14 +194,6 @@
... operations='example.articleInitializer'
... storeInput='True'
... />
- ... <information
- ... keyface='example.ITextConfig'
- ... configuration='example.articleTextDefaults'
- ... />
- ... <information
- ... keyface='example.INoteConfig'
- ... configuration='example.articleNoteDefaults'
- ... />
... </generic:content>
... ''')
Modified: zope.generic/trunk/src/zope/generic/content/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/content/README.txt 2006-05-04 00:56:11 UTC (rev 67959)
+++ zope.generic/trunk/src/zope/generic/content/README.txt 2006-05-04 08:00:22 UTC (rev 67960)
@@ -154,23 +154,31 @@
... print 'Guguseli from object event.'
-After all we register our component using the type directive:
+After all we register our component using the informationProvider and content
+directive:
>>> registerDirective('''
+ ... <generic:informationProvider
+ ... keyface="example.IBarMarker"
+ ... >
+ ... <information
+ ... keyface='example.IAnyConfiguration'
+ ... configuration='example.typedata'
+ ... />
+ ... </generic:informationProvider>
+ ... ''')
+
+ >>> registerDirective('''
... <generic:content
... keyface="example.IBarMarker"
... label='Bar Type' hint='Bla bla bla.'
... >
- ... <factory
+ ... <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'
Modified: zope.generic/trunk/src/zope/generic/content/meta.zcml
===================================================================
--- zope.generic/trunk/src/zope/generic/content/meta.zcml 2006-05-04 00:56:11 UTC (rev 67959)
+++ zope.generic/trunk/src/zope/generic/content/meta.zcml 2006-05-04 08:00:22 UTC (rev 67960)
@@ -11,11 +11,6 @@
>
<meta:subdirective
- name="information"
- schema="zope.generic.informationprovider.metadirectives.IInformationSubdirective"
- />
-
- <meta:subdirective
name="factory"
schema=".metadirectives.IFactorySubdirective"
/>
Modified: zope.generic/trunk/src/zope/generic/content/metaconfigure.py
===================================================================
--- zope.generic/trunk/src/zope/generic/content/metaconfigure.py 2006-05-04 00:56:11 UTC (rev 67959)
+++ zope.generic/trunk/src/zope/generic/content/metaconfigure.py 2006-05-04 08:00:22 UTC (rev 67960)
@@ -18,18 +18,22 @@
__docformat__ = 'restructuredtext'
+from zope.component.interface import provideInterface
from zope.configuration.exceptions import ConfigurationError
+from zope.interface import alsoProvides
from zope.generic.adapter.metaconfigure import adapterDirective
+from zope.generic.face import IConfaceType
+from zope.generic.face import IKeyfaceType
from zope.generic.factory.metaconfigure import factoryDirective
-from zope.generic.informationprovider.metaconfigure import InformationProviderDirective
from zope.generic.handler.metaconfigure import handlerDirective
+from zope.generic.informationprovider.metaconfigure import ensureInformationProvider
from zope.generic.face import IUndefinedContext
-class ContentDirective(InformationProviderDirective):
+class ContentDirective(object):
"""Provide a new logical type."""
# mark types with a type marker type
@@ -38,9 +42,26 @@
def __init__(self, _context, keyface, label=None, hint=None):
# register types within the type information registry
- conface = IUndefinedContext
- super(ContentDirective, self).__init__(_context, keyface, conface)
+ if IConfaceType.providedBy(keyface):
+ raise ConfigurationError('Key interface %s can not be registered '
+ 'as context interface too.' %
+ keyface.__name__)
+ # assign variables for the subdirecitives
+ self._keyface = keyface
+ self._context = _context
+ self._conface = conface = IUndefinedContext
+
+ # provide type as soon as possilbe
+ if not IKeyfaceType.providedBy(keyface):
+ provideInterface(None, keyface, IKeyfaceType)
+
+ if not IConfaceType.providedBy(conface):
+ provideInterface(None, conface, IConfaceType)
+
+ # ensure the corresponding information provider
+ ensureInformationProvider(keyface, conface)
+
def factory(self, _context, class_, operations=(), input=None,
providesFace=True, notifyCreated=False, storeInput=False):
"""Add factory."""
Modified: zope.generic/trunk/src/zope/generic/content/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/content/testing.py 2006-05-04 00:56:11 UTC (rev 67959)
+++ zope.generic/trunk/src/zope/generic/content/testing.py 2006-05-04 08:00:22 UTC (rev 67960)
@@ -24,6 +24,7 @@
import zope.generic.directlyprovides.testing
import zope.generic.factory.testing
import zope.generic.handler.testing
+import zope.generic.informationprovider.testing
import zope.generic.face.testing
import zope.generic.operation.testing
import zope.generic.testing.testing
@@ -69,6 +70,7 @@
zope.generic.directlyprovides.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)
zope.generic.factory.testing.setUp(doctest)
zope.generic.adapter.testing.setUp(doctest)
@@ -84,6 +86,7 @@
zope.generic.adapter.testing.tearDown(doctest)
zope.generic.factory.testing.tearDown(doctest)
zope.generic.operation.testing.tearDown(doctest)
+ zope.generic.informationprovider.testing.tearDown(doctest)
zope.generic.configuration.testing.tearDown(doctest)
zope.generic.face.testing.tearDown(doctest)
zope.generic.directlyprovides.testing.tearDown(doctest)
More information about the Checkins
mailing list