[Zope-CVS] CVS: Products/Event - EventRegistry.py:1.7

Chris McDonough chrism@zope.com
Tue, 3 Jun 2003 14:33:20 -0400


Update of /cvs-repository/Products/Event
In directory cvs.zope.org:/tmp/cvs-serv32510

Modified Files:
	EventRegistry.py 
Log Message:
Add new method to event registry:  listEventsWhichExtend, which receives an interface.  Returned are the keys into the registry for the interfaces which extend the passed in interface.


=== Products/Event/EventRegistry.py 1.6 => 1.7 ===
--- Products/Event/EventRegistry.py:1.6	Tue Oct  8 13:06:05 2002
+++ Products/Event/EventRegistry.py	Tue Jun  3 14:32:49 2003
@@ -43,6 +43,29 @@
         return [(k, v['title'], v['description'])
                 for k, v in _registry.items()]
 
+    def listEventsWhichExtend(self, interface, with_metadata=0, strict=1):
+        """ List the registered event interfaces which extend the
+        interface which is passed in as 'interface'
+
+        - if 'with_metadata', then return a sequence of (key, title,
+          description) tuples.
+
+        - otherwise, return a sequence of keys.
+
+        - if 'strict' is specified, it is passed to the 'extends' method
+          of an interface during the test for extension.
+
+        """
+        l = []
+        for k, v in _registry.items():
+            i = v['interface']
+            if i.extends(interface, strict):
+                if with_metadata:
+                    l.append((k, v['title'], v['description']))
+                else:
+                    l.append(k)
+        return l
+
     def getEvent(self, key):
         """Look up the event information.