[z3-checkins] r13887 - z3/pipelines/trunk
ivo at codespeak.net
ivo at codespeak.net
Sat Jun 25 18:41:35 CEST 2005
Author: ivo
Date: Sat Jun 25 18:41:34 2005
New Revision: 13887
Added:
z3/pipelines/trunk/filters.py
Modified:
z3/pipelines/trunk/configure.zcml
z3/pipelines/trunk/metaconfigure.py
z3/pipelines/trunk/metadirectives.py
z3/pipelines/trunk/registry.py
Log:
lots of glue to get things to work
Modified: z3/pipelines/trunk/configure.zcml
==============================================================================
--- z3/pipelines/trunk/configure.zcml (original)
+++ z3/pipelines/trunk/configure.zcml Sat Jun 25 18:41:34 2005
@@ -1,6 +1,6 @@
<configure
xmlns="http://namespaces.zope.org/zope"
- xmlns:event="http://namespaces.zope.org/event"
+ xmlns:pipeline="http://namespaces.zope.org/pipeline"
>
<subscriber
@@ -8,31 +8,41 @@
handler=".event.doResponsePipeline"
/>
-<!--
-<pipeline
- for="zope.app.publication.interfaces.IEndRequestEvent"
+<pipeline:pipeline
+ package="pipelines.pipeline"
+ name="foo"
>
- <filter
+ <pipeline:filter
id="tidy"
- function=".filters.tidy"
+ factory=".filters.tidy"
/>
- <filter
+ <!--
+ <pipeline:filter
id="domify"
function=".filters.createResponseDOM"
/>
- <filter
+ <pipeline:filter
id="cleanup"
function=".filters.injectRelatedContent"
/>
- <filter
+ <pipeline:filter
id="deliverance"
function=".filters.deliverance"
/>
- <filter
+ <pipeline:filter
id="collapse"
function=".filters.collapseResponseDOM"
- />
-</pipeline>
- -->
+ /> -->
+
+</pipeline:pipeline>
+
+<utility
+ provides="pipelines.interfaces.IPipeline"
+ component="pipelines.pipeline.foo"
+ name="foo" />
+
+<subscriber
+ for="zope.app.publication.interfaces.IEndRequestEvent"
+ handler="pipelines.pipeline.foo" />
</configure>
Added: z3/pipelines/trunk/filters.py
==============================================================================
--- (empty file)
+++ z3/pipelines/trunk/filters.py Sat Jun 25 18:41:34 2005
@@ -0,0 +1,11 @@
+# demo package, to test if everything works
+from pipelines.interfaces import IFilter
+from zope.interface import Interface, implements
+
+class tidy(object):
+ implements(IFilter)
+
+ def __call__(self, data):
+ pass
+
+
Modified: z3/pipelines/trunk/metaconfigure.py
==============================================================================
--- z3/pipelines/trunk/metaconfigure.py (original)
+++ z3/pipelines/trunk/metaconfigure.py Sat Jun 25 18:41:34 2005
@@ -1,18 +1,22 @@
from zope.app.component.metaconfigure import utility
-from pipelines.interface import IPipeline
+from pipelines.interfaces import IPipeline
from pipelines.pipeline import Pipeline
class pipeline(object):
- def __init__(self, _context, for_):
- self.for_ = for_
+ def __init__(self, _context, package, name):
+ self.package = package
+ self.name = name
self.filters = []
- def filter(self, _context, id):
- self.filters.append(filter(_context, id))
+ def filter(self, _context, id, factory=None, component=None):
+ self.filters.append(filter(_context, id, component, factory))
def __call__(self):
pipe = Pipeline(self.filters)
- ## register the pipeline somewhere
+ pipe.__dict__['__name__'] = self.name
+ setattr(self.package, self.name, pipe)
+ # setattr(self.package, pipe.getName(), pipe)
+ # self.package[self.name] = pipe
def filter(_context, id, component=None, factory=None):
if factory:
Modified: z3/pipelines/trunk/metadirectives.py
==============================================================================
--- z3/pipelines/trunk/metadirectives.py (original)
+++ z3/pipelines/trunk/metadirectives.py Sat Jun 25 18:41:34 2005
@@ -1,20 +1,25 @@
from zope.app.interface import Interface
-from zope.configuration.fields import Tokens, GlobalObject
-from zope.schema import Id
+from zope.configuration.fields import GlobalObject, PythonIdentifier
+from zope.schema import Id, TextLine
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(),
- ),
+ package = GlobalObject(
+ title=_("Package where the Pipeline will live in"),
+ description=_("Python name of the package to which the pipeline"
+ "will be added. This must identify a module using the"
+ " full dotted name."),
+ required=True,
+ )
+
+ name = PythonIdentifier(
+ title=_("The name of the pipeline."),
+ description=_("The name pipeline within the package."),
+ required=True,
)
class IFilterSubdirective(Interface):
- id = Id(
+ id = TextLine(
title=_("ID"),
required=False,
)
Modified: z3/pipelines/trunk/registry.py
==============================================================================
--- z3/pipelines/trunk/registry.py (original)
+++ z3/pipelines/trunk/registry.py Sat Jun 25 18:41:34 2005
@@ -5,6 +5,9 @@
from zope.app.zapi import getGlobalSiteManager
from pipelines.pipeline import Pipeline
+from zope.component.exceptions import ComponentLookupError
+from pipelines.interfaces import IPipelineUtility
+
def registerPipeline(for_, filters):
gsm = getGlobalSiteManager()
pipeline = Pipeline(filters)
More information about the z3-checkins
mailing list