Commits

Olemis Lang committed 11d208e

Trac #11148 : method '_get_listeners_for_interface' can be completely removed now by reusing 'ExtensionPoint'

Comments (0)

Files changed (1)

t11148/t11148_r11782_IEntityChangeListener_extends_with_prefix.diff

 
 diff -r 8d0c3223a818 trac/core.py
 --- a/trac/core.py	Thu Apr 18 14:30:21 2013 +0000
-+++ b/trac/core.py	Mon Apr 22 10:52:53 2013 -0500
++++ b/trac/core.py	Mon Apr 22 11:11:32 2013 -0500
 @@ -165,8 +165,30 @@
  
          locals_.setdefault('_implements', []).extend(interfaces)
  
  
  class ComponentManager(object):
-@@ -236,3 +258,63 @@
+@@ -236,3 +258,57 @@
          with the given class will not be available.
          """
          return True
 +class ListenerNotifier(Component):
 +    METHOD_DELIMITER = "_"
 +
-+    def _get_listeners_for_interface(self, interface):
-+        """Return a list of components that declare to implement the
-+        extension point interface.
-+        """
-+        classes = ComponentMeta._registry.get(interface, ())
-+        components = [self.env[cls] for cls in classes]
-+        return [c for c in components if c]
-+
 +    def notify(self, method, *args):
 +        interface = method.im_class
 +        method_name = method.__name__
 +                "Notification interface can not be None. " +
 +                "Target method name is %s" % method_name)
 +
-+        for listener in self._get_listeners_for_interface(interface):
++        xp = ExtensionPoint(interface)
++        # FIXME : Sender component rather than self. Change method signature
++        for listener in xp.extensions(self):
 +            getattr(listener, method_name)(*args)
 +
 +        #TBD: we can also call listeners implemented IEntityChangeListener here
 +
 diff -r 8d0c3223a818 trac/ticket/model.py
 --- a/trac/ticket/model.py	Thu Apr 18 14:30:21 2013 +0000
-+++ b/trac/ticket/model.py	Mon Apr 22 10:52:53 2013 -0500
++++ b/trac/ticket/model.py	Mon Apr 22 11:11:32 2013 -0500
 @@ -25,7 +25,8 @@
  from trac.attachment import Attachment
  from trac import core
          """
 diff -r 8d0c3223a818 trac/ticket/tests/model.py
 --- a/trac/ticket/tests/model.py	Thu Apr 18 14:30:21 2013 +0000
-+++ b/trac/ticket/tests/model.py	Mon Apr 22 10:52:53 2013 -0500
++++ b/trac/ticket/tests/model.py	Mon Apr 22 11:11:32 2013 -0500
 @@ -12,8 +12,8 @@
  from trac.core import TracError, implements
  from trac.resource import ResourceNotFound