Replace "get_utilities_for" by "get_all_utilities_registered_for" to get all registered utilities for a given interface
authorThierry Florac <thierry.florac@onf.fr>
Fri, 20 Jan 2017 15:39:58 +0100
changeset 66 991e5033836f
parent 65 e4e1df663072
child 67 aaf228e67189
Replace "get_utilities_for" by "get_all_utilities_registered_for" to get all registered utilities for a given interface
src/pyams_content/root/zmi/__init__.py
--- a/src/pyams_content/root/zmi/__init__.py	Fri Jan 20 15:36:31 2017 +0100
+++ b/src/pyams_content/root/zmi/__init__.py	Fri Jan 20 15:39:58 2017 +0100
@@ -48,7 +48,7 @@
 from pyams_template.template import template_config
 from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
 from pyams_utils.list import unique
-from pyams_utils.registry import get_utility, get_utilities_for
+from pyams_utils.registry import get_utility, get_all_utilities_registered_for
 from pyams_viewlet.manager import viewletmanager_config
 from pyams_viewlet.viewlet import viewlet_config
 from pyams_zmi.view import AdminView
@@ -145,7 +145,7 @@
     def values(self):
         catalog = get_utility(ICatalog)
         params = None
-        for name, tool in get_utilities_for(ISharedTool):
+        for tool in get_all_utilities_registered_for(ISharedTool):
             workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
             query = Eq(catalog['content_type'], tool.shared_content_type) & \
                     Any(catalog['workflow_state'], workflow.waiting_states)
@@ -190,7 +190,7 @@
     def values(self):
         catalog = get_utility(ICatalog)
         params = None
-        for name, tool in get_utilities_for(ISharedTool):
+        for tool in get_all_utilities_registered_for(ISharedTool):
             workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
             query = Eq(catalog['content_type'], tool.shared_content_type) & \
                     Any(catalog['workflow_state'], workflow.waiting_states) & \
@@ -228,7 +228,7 @@
     def values(self):
         catalog = get_utility(ICatalog)
         params = None
-        for name, tool in get_utilities_for(ISharedTool):
+        for tool in get_all_utilities_registered_for(ISharedTool):
             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)))
@@ -288,7 +288,7 @@
         catalog = get_utility(ICatalog)
         profile = IAdminProfile(self.request.principal)
         params = None
-        for name, tool in get_utilities_for(ISharedTool):
+        for tool in get_all_utilities_registered_for(ISharedTool):
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Any(catalog['oid'], profile.favorites or ()))
             params = params | query if params else query
@@ -346,7 +346,7 @@
     def values(self):
         catalog = get_utility(ICatalog)
         params = None
-        for name, tool in get_utilities_for(ISharedTool):
+        for tool in get_all_utilities_registered_for(ISharedTool):
             workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Or(Eq(catalog['role:owner'], self.request.principal.id),
@@ -406,7 +406,7 @@
     def values(self):
         catalog = get_utility(ICatalog)
         params = None
-        for name, tool in get_utilities_for(ISharedTool):
+        for tool in get_all_utilities_registered_for(ISharedTool):
             workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Or(Eq(catalog['role:owner'], self.request.principal.id),
@@ -466,7 +466,7 @@
     def values(self):
         catalog = get_utility(ICatalog)
         params = None
-        for name, tool in get_utilities_for(ISharedTool):
+        for tool in get_all_utilities_registered_for(ISharedTool):
             workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Or(Eq(catalog['role:owner'], self.request.principal.id),
@@ -526,7 +526,7 @@
     def values(self):
         catalog = get_utility(ICatalog)
         params = None
-        for name, tool in get_utilities_for(ISharedTool):
+        for tool in get_all_utilities_registered_for(ISharedTool):
             workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Or(Eq(catalog['role:owner'], self.request.principal.id),
@@ -588,7 +588,7 @@
         catalog = get_utility(ICatalog)
         params = None
         principal_id = self.request.principal.id
-        for name, tool in get_utilities_for(ISharedTool):
+        for tool in get_all_utilities_registered_for(ISharedTool):
             workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Or(Eq(catalog['role:owner'], principal_id),
@@ -676,7 +676,7 @@
     def values(self):
         catalog = get_utility(ICatalog)
         params = None
-        for name, tool in get_utilities_for(ISharedTool):
+        for tool in get_all_utilities_registered_for(ISharedTool):
             workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
             query = And(Eq(catalog['content_type'], tool.shared_content_type),
                         Any(catalog['workflow_state'], workflow.published_states))
@@ -742,7 +742,7 @@
     def values(self):
         catalog = get_utility(ICatalog)
         params = None
-        for name, tool in get_utilities_for(ISharedTool):
+        for tool in get_all_utilities_registered_for(ISharedTool):
             query = Eq(catalog['content_type'], tool.shared_content_type)
             params = params | query if params else query
         return unique(CatalogResultSet(CatalogQuery(catalog).query(params,