[z3-checkins] r13864 - z3/pipelines/trunk
ivo at codespeak.net
ivo at codespeak.net
Sat Jun 25 17:04:42 CEST 2005
Author: ivo
Date: Sat Jun 25 17:04:41 2005
New Revision: 13864
Added:
z3/pipelines/trunk/meta.zcml
z3/pipelines/trunk/metaconfigure.py
z3/pipelines/trunk/metadirectives.py
Log:
configuration directives implemented
Added: z3/pipelines/trunk/meta.zcml
==============================================================================
--- (empty file)
+++ z3/pipelines/trunk/meta.zcml Sat Jun 25 17:04:41 2005
@@ -0,0 +1,18 @@
+<configure xmlns:meta="http://namespaces.zope.org/meta">
+ <meta:directives namespace="http://namespaces.zope.org/pipeline">
+ <meta:complexDirective
+ name="pipeline"
+ schema=".metadirectives.IPipelineDirective"
+ handler=".metaconfigure.pipeline">
+
+ <meta:subdirective
+ name="filter"
+ schema=".metadirectives.IFilterSubdirective" />
+
+
+ </meta:complexDirective>
+ </meta:directives>
+</configure>
+
+
+
Added: z3/pipelines/trunk/metaconfigure.py
==============================================================================
--- (empty file)
+++ z3/pipelines/trunk/metaconfigure.py Sat Jun 25 17:04:41 2005
@@ -0,0 +1,24 @@
+from zope.app.component.metaconfigure import utility
+from pipelines.interface import IPipeline
+from pipelines.pipeline import Pipeline
+
+class pipeline(object):
+ def __init__(self, _context, for_):
+ self.for_ = for_
+ self.filters = []
+
+ def filter(self, _context, id):
+ self.filters.append(filter(_context, id))
+
+ def __call__(self):
+ pipe = Pipeline(self.filters)
+ ## register the pipeline somewhere
+
+def filter(_context, id, component=None, factory=None):
+ if factory:
+ if component:
+ raise TypeError("Can't specify factory and component.")
+ component = factory()
+ return component
+
+
Added: z3/pipelines/trunk/metadirectives.py
==============================================================================
--- (empty file)
+++ z3/pipelines/trunk/metadirectives.py Sat Jun 25 17:04:41 2005
@@ -0,0 +1,38 @@
+from zope.app.interface import Interface
+from zope.configuration.fields import Tokens, GlobalObject
+from zope.schema import Id
+from zope.app.i18n import ZopeMessageIDFactory as _
+
+class IPipelineDirective(Interface):
+ for_ = Tokens(
+ title=_("Interfaces or classes that this subscriber depends on"),
+ description=_("This should be a list of interfaces or classes"),
+ required=False,
+ value_type=GlobalObject(
+ missing_value = object(),
+ ),
+ )
+
+class IFilterSubdirective(Interface):
+ id = Id(
+ title=_("ID"),
+ required=False,
+ )
+ component = GlobalObject(
+ title=_("Component to use"),
+ description=_("Python name of the implementation object. This"
+ " must identify an object in a module using the"
+ " full dotted name. If specified, the"
+ " ``factory`` field must be left blank."),
+ required=False,
+ )
+
+ factory = GlobalObject(
+ title=_("Factory"),
+ description=_("Python name of a factory which can create the"
+ " implementation object. This must identify an"
+ " object in a module using the full dotted name."
+ " If specified, the ``component`` field must"
+ " be left blank."),
+ required=False,
+ )
More information about the z3-checkins
mailing list