[Zope3-checkins] CVS: Packages3/workflow/browser/stateful - configure.zcml:1.9 filteradapter.py:1.2 interfaces.py:1.2

Christian Theune ct@gocept.com
Thu, 27 Mar 2003 11:07:20 -0500


Update of /cvs-repository/Packages3/workflow/browser/stateful
In directory cvs.zope.org:/tmp/cvs-serv2936/stateful

Modified Files:
	configure.zcml filteradapter.py interfaces.py 
Log Message:
 - Refactored content filter so it filters single objects
   and made a convenience method to filter lists of objects



=== Packages3/workflow/browser/stateful/configure.zcml 1.8 => 1.9 ===
--- Packages3/workflow/browser/stateful/configure.zcml:1.8	Thu Mar 27 09:54:24 2003
+++ Packages3/workflow/browser/stateful/configure.zcml	Thu Mar 27 11:07:19 2003
@@ -182,7 +182,7 @@
 <adapter
     factory=".filteradapter.FilterAdapter"
     provides=".interfaces.IContentFilterAdapter"
-    for="zope.app.interfaces.container.IContentContainer"
+    for="zope.app.interfaces.annotation.IAttributeAnnotatable"
     permission="zope.View" />       <!-- XXX is this permission right? -->
 
 </zopeConfigure>


=== Packages3/workflow/browser/stateful/filteradapter.py 1.1 => 1.2 ===
--- Packages3/workflow/browser/stateful/filteradapter.py:1.1	Thu Mar 27 09:54:24 2003
+++ Packages3/workflow/browser/stateful/filteradapter.py	Thu Mar 27 11:07:19 2003
@@ -30,20 +30,26 @@
     def __init__(self, context):
         self.context = context
 
-    def filterByState(self, objList, state, workflow='default'):
+    def filterListByState(self, objList, state, workflow='default'):
         """See IContentFilterAdapter"""
         res = []
 
         for obj in objList:
-            adapter = queryAdapter(obj, IProcessInstanceContainer)
-            if adapter:
-                for item in adapter.values():
-                    if item.processDefinitionName != workflow:
-                        continue
-                    if item.status == state:
-                        res.append(obj)
-                        break
-        return res
+            if self.filterObjectByState(obj, state, workflow):
+                res.append(obj)
 
+        return res
 
+    def filterObjectByState(self, object, state, workflow='default'):
+        """See IContentFilterAdapter"""
+        adapter = queryAdapter(object, IProcessInstanceContainer)
+        if not adapter:
+            return False
+            
+        for item in adapter.values():
+            if item.processDefinitionName != workflow:
+                continue
+            if item.status == state:
+                return True
 
+        return False                


=== Packages3/workflow/browser/stateful/interfaces.py 1.1 => 1.2 ===
--- Packages3/workflow/browser/stateful/interfaces.py:1.1	Thu Mar 27 09:54:24 2003
+++ Packages3/workflow/browser/stateful/interfaces.py	Thu Mar 27 11:07:19 2003
@@ -20,7 +20,7 @@
 
 class IContentFilterAdapter(Interface):
 
-    def filterByState(objList, state, workflow='default'):
+    def filterListByState(objList, state, workflow='default'):
         """Filter a list of objects according to given workflow and state
 
         objList  ... list of objects
@@ -28,3 +28,8 @@
                       objects must be
         workflow ... name of a workflow to which result objects must be attached
         """
+
+    def filterObjectByState(object, state, workflow='default'):
+        """Filter an object according to the given workflow and state."""
+
+