Use simple adapter to get workflow associated with a given tool
authorThierry Florac <thierry.florac@onf.fr>
Wed, 12 Jul 2017 11:44:19 +0200
changeset 103 8627e24b348e
parent 102 58cde0290f69
child 104 b5426d5f0990
Use simple adapter to get workflow associated with a given tool
src/pyams_content/root/zmi/__init__.py
--- a/src/pyams_content/root/zmi/__init__.py	Wed Jul 12 11:43:19 2017 +0200
+++ b/src/pyams_content/root/zmi/__init__.py	Wed Jul 12 11:44:19 2017 +0200
@@ -146,7 +146,7 @@
         catalog = get_utility(ICatalog)
         params = None
         for tool in get_all_utilities_registered_for(ISharedTool):
-            workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
+            workflow = IWorkflow(tool)
             query = Eq(catalog['content_type'], tool.shared_content_type) & \
                     Any(catalog['workflow_state'], workflow.waiting_states)
             params = params | query if params else query
@@ -191,7 +191,7 @@
         catalog = get_utility(ICatalog)
         params = None
         for tool in get_all_utilities_registered_for(ISharedTool):
-            workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
+            workflow = IWorkflow(tool)
             query = Eq(catalog['content_type'], tool.shared_content_type) & \
                     Any(catalog['workflow_state'], workflow.waiting_states) & \
                     Eq(catalog['workflow_principal'], self.request.principal.id)
@@ -347,7 +347,7 @@
         catalog = get_utility(ICatalog)
         params = None
         for tool in get_all_utilities_registered_for(ISharedTool):
-            workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
+            workflow = IWorkflow(tool)
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Or(Eq(catalog['role:owner'], self.request.principal.id),
                            Eq(catalog['role:contributor'], self.request.principal.id)),
@@ -407,7 +407,7 @@
         catalog = get_utility(ICatalog)
         params = None
         for tool in get_all_utilities_registered_for(ISharedTool):
-            workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
+            workflow = IWorkflow(tool)
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Or(Eq(catalog['role:owner'], self.request.principal.id),
                            Eq(catalog['role:contributor'], self.request.principal.id)),
@@ -467,7 +467,7 @@
         catalog = get_utility(ICatalog)
         params = None
         for tool in get_all_utilities_registered_for(ISharedTool):
-            workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
+            workflow = IWorkflow(tool)
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Or(Eq(catalog['role:owner'], self.request.principal.id),
                            Eq(catalog['role:contributor'], self.request.principal.id)),
@@ -527,7 +527,7 @@
         catalog = get_utility(ICatalog)
         params = None
         for tool in get_all_utilities_registered_for(ISharedTool):
-            workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
+            workflow = IWorkflow(tool)
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Or(Eq(catalog['role:owner'], self.request.principal.id),
                            Eq(catalog['role:contributor'], self.request.principal.id)),
@@ -589,7 +589,7 @@
         params = None
         principal_id = self.request.principal.id
         for tool in get_all_utilities_registered_for(ISharedTool):
-            workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
+            workflow = IWorkflow(tool)
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Or(Eq(catalog['role:owner'], principal_id),
                            Eq(catalog['role:contributor'], principal_id)),
@@ -677,7 +677,7 @@
         catalog = get_utility(ICatalog)
         params = None
         for tool in get_all_utilities_registered_for(ISharedTool):
-            workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
+            workflow = IWorkflow(tool)
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Any(catalog['workflow_state'], workflow.published_states))
             params = params | query if params else query