Added new "component" registry utility module ZTK-1.1
authorThierry Florac <thierry.florac@onf.fr>
Tue, 03 Dec 2013 11:46:14 +0100
branchZTK-1.1
changeset 239 96765451d8d7
parent 238 26773e68d3d3
child 240 6a5ad9cc00c5
Added new "component" registry utility module
src/ztfy/utils/component.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/utils/component.py	Tue Dec 03 11:46:14 2013 +0100
@@ -0,0 +1,31 @@
+### -*- coding: utf-8 -*- ####################################################
+##############################################################################
+#
+# Copyright (c) 2012 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+
+# import standard packages
+
+# import Zope3 interfaces
+
+# import local interfaces
+
+# import Zope3 packages
+from zope.component import getUtilitiesFor
+
+# import local packages
+
+
+def getRegistryNames(component, interface):
+    """Get registration names of given component for given interface"""
+    return [name for (name, utility) in getUtilitiesFor(interface) if component is utility]