[Zope3-checkins] CVS: zopeproducts/zwiki - meta.zcml:1.3 metaconfigure.py:1.5
Philipp von Weitershausen
philikon@philikon.de
Wed, 30 Jul 2003 00:22:17 -0400
Update of /cvs-repository/zopeproducts/zwiki
In directory cvs.zope.org:/tmp/cvs-serv31369
Modified Files:
meta.zcml metaconfigure.py
Log Message:
Zwiki was broken because of zcmlgeddon. I fixed this using the new way to
register a directive:
* write a schema for each directive
* declare the directives using the new 'meta' namespace
BTW: Jim, zcmlgeddon rocks.
=== zopeproducts/zwiki/meta.zcml 1.2 => 1.3 ===
--- zopeproducts/zwiki/meta.zcml:1.2 Sat Apr 12 19:05:34 2003
+++ zopeproducts/zwiki/meta.zcml Wed Jul 30 00:22:12 2003
@@ -1,59 +1,19 @@
-<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
-
- <directives namespace="http://namespaces.zope.org/wiki">
+<zopeConfigure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:meta="http://namespaces.zope.org/meta">
+
+ <meta:complexDirective
+ namespace="http://namespaces.zope.org/wiki"
+ name="sourcetype"
+ schema=".metaconfigure.ISourceTypeDirective"
+ handler=".metaconfigure.sourcetype"
+ >
+
+ <meta:subdirective
+ name="renderer"
+ schema=".metaconfigure.IRendererDirective"
+ />
- <directive name="sourcetype" handler=".metaconfigure.sourcetype">
-
- <description>
- The renderers directive specifies how a particular source text can
- be rendered for various view types. It also generates a registry of
- available source types.
- </description>
-
- <attribute name="interface" required="yes">
- <description>
- The for attribute specifies a interface for specifying the
- particular source type.
- </description>
- </attribute>
-
- <attribute name="class" required="yes">
- <description>
- The for attribute specifies the class that is implementing this
- source type.
- </description>
- </attribute>
-
- <attribute name="title" required="yes">
- <description>
- Provides a title for the source type.
- </description>
- </attribute>
-
- <subdirective name="renderer">
- <description>
- Register a renderer for a paricular output interface, such as
- IBrowserView.
- </description>
-
- <attribute name="for" required="yes">
- <description>
- Specifies the interface of the output type (i.e. browser) for
- which this view is being registered.
- </description>
- </attribute>
-
- <attribute name="factory" required="yes">
- <description>
- Specifies the factory that is used to create the view on the
- source.
- </description>
- </attribute>
-
- </subdirective>
-
- </directive>
-
- </directives>
+ </meta:complexDirective>
</zopeConfigure>
=== zopeproducts/zwiki/metaconfigure.py 1.4 => 1.5 ===
--- zopeproducts/zwiki/metaconfigure.py:1.4 Thu Jun 5 09:34:24 2003
+++ zopeproducts/zwiki/metaconfigure.py Wed Jul 30 00:22:12 2003
@@ -17,53 +17,86 @@
"""
from zope.interface import implements, classProvides
-from zope.configuration.interfaces import INonEmptyDirective
-from zope.configuration.interfaces import ISubdirectiveHandler
-from zope.configuration.action import Action
+from zope.interface import Interface
+from zope import schema
+
+from zope.configuration.fields import GlobalObject
from zope.configuration.exceptions import ConfigurationError
from zope.app.component.metaconfigure import handler
from zopeproducts.zwiki.sourcetype import SourceTypes
-class sourcetype:
+class ISourceTypeDirective(Interface):
+ """
+ The renderers directive specifies how a particular source text can
+ be rendered for various view types. It also generates a registry
+ of available source types.
+ """
+
+ interface = GlobalObject(
+ title=u"Interface",
+ description=u"The for attribute specifies a interface for specifying the particular source type.",
+ required=True
+ )
+
+ class_ = GlobalObject(
+ title=u"Class",
+ description=u"The for attribute specifies the class that is implementing this source type.",
+ required=True
+ )
+
+ title = schema.BytesLine(
+ title=u"Title",
+ description=u"Provides a title for the source type.",
+ required=True
+ )
+
+class IRendererDirective(Interface):
+ """
+ Register a renderer for a paricular output interface, such as
+ IBrowserView.
+ """
+
+ for_ = GlobalObject(
+ title=u"Interface of the output type",
+ description=u"Specifies the interface of the output type (i.e. browser) for which this view is being registered.",
+ required=True
+ )
+
+ factory = GlobalObject(
+ title=u"Factory",
+ description=u"Specifies the factory that is used to create the view on the source.",
+ required=True
+ )
- classProvides(INonEmptyDirective)
- implements(ISubdirectiveHandler)
+class sourcetype:
def __init__(self, _context, interface, class_, title=u''):
- self.iface = _context.resolve(interface)
- self.klass = _context.resolve(class_)
+ self._context = _context
+ self.iface = interface
+ self.klass = class_
self.title = title
self.renderers = []
def renderer(self, _context, for_, factory):
if for_ == '*':
for_ = None
- self.renderers.append((_context.resolve(for_),
- _context.resolve(factory)))
- return ()
+ self.renderers.append((for_, factory))
def __call__(self):
- actions = []
-
+ _context = self._context
# register each renderer as a view
for iface, factory in self.renderers:
- actions.append(Action(
+ _context.action(
discriminator = ('view', self.iface, None, iface, 'default'),
callable=handler,
args = ('Views', 'provideView',
self.iface, None, iface, factory, 'default')
)
- )
-
+
# register source type in WikiSourceTypeRegistry
- actions.append(Action(
+ _context.action(
discriminator = ('zwiki source type', self.title, self.iface),
callable=SourceTypes.provide,
args = (self.title, self.iface, self.klass)
)
- )
-
- return actions
-
-