Author: jmorliaguet
Date: Sun Oct 30 10:18:09 2005
New Revision: 28812

Modified:
   z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/filters/metaconfigure.py
Log:

- simpler filter configuration



Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py        
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py        
Sun Oct 30 10:18:09 2005
@@ -318,9 +318,9 @@
                         % (filter_name, repr(adapted)))
                     continue
 
-            # the filter id is a display adapter
+            # the filter id is a factory
             elif IFilter.providedBy(filter_id):
-                filter = filter_id(display)
+                filter = filter_id()
 
             # the filter id is a page template applied to the rendered element
             elif isinstance(filter_id, ViewPageTemplateFile):

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/filters/metaconfigure.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/filters/metaconfigure.py 
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/filters/metaconfigure.py 
    Sun Oct 30 10:18:09 2005
@@ -39,34 +39,42 @@
     if not name:
         raise ConfigurationError("Must specify the filter name.")
 
-    if not (for_ or factory or predicate or template):
-        raise ConfigurationError("Filter information is missing.")
-
     if name in filter_registry:
         raise ConfigurationError, \
             "A filter with the name '%s' has already been registered." % name
 
-    if not for_:
-        raise ConfigurationError, \
-            "Must specify the interface of the adapted element."
+    if not (predicate or factory or template):
+        raise ConfigurationError(
+            "Must specify a predicate or a factory or a template.")
 
-    if not (factory or template):
-        raise ConfigurationError("Must specify a filter factory or a 
template.")
+    # predicate, for_, factory
+    if predicate:
+        if not (for_ and factory):
+            raise ConfigurationError, \
+                "With a predicate, must specify an interface and a factory."
+
+        # zope:adapter
+        from cpsskins.browser.rendering.interfaces import IFilter
+        _context.action(
+            discriminator = ('adapter', factory, for_, name),
+            callable = provideAdapter,
+            args = (factory, (for_,), IFilter, name))
+        filter_registry.register(name, predicate)
 
-    if factory and template:
-        raise ConfigurationError(
-            "Cannot specify both a filter factory and a template.")
+    # factory
+    elif factory:
+        if template or for_:
+            raise ConfigurationError(
+                "With a factory, cannot specify a template or an interface.")
+        filter_registry.register(name, factory)
 
-    if template:
+    # template
+    elif template:
+        if for_:
+            raise ConfigurationError(
+                "With a template, cannot specify an interface")
         factory = pagetemplate.ViewPageTemplateFile(template)
-
-    # zope:adapter
-    from cpsskins.browser.rendering.interfaces import IFilter
-    _context.action(
-        discriminator = ('adapter', factory, for_, name),
-        callable = provideAdapter,
-        args = (factory, (for_,), IFilter, name),
-        )
+        filter_registry.register(name, factory)
 
     # register resources
     if stylesheet:
@@ -75,10 +83,3 @@
                  name=stylesheet_name,
                  file=stylesheet)
 
-    # register the predicate or the filter factory
-    if predicate:
-        filter_registry.register(name, predicate)
-
-    elif factory:
-        filter_registry.register(name, factory)
-
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to