no functional changes.
Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
ryu/base/app_manager.py | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py
index ec42f97..821a4b5 100644
--- a/ryu/base/app_manager.py
+++ b/ryu/base/app_manager.py
@@ -176,13 +176,28 @@ class RyuApp(object):
observers.pop(name, None)
def get_handlers(self, ev, state=None):
- handlers = self.event_handlers.get(ev.__class__, [])
+ """Returns a list of handlers for the specific event.
+
+ :param ev: The event to handle.
+ :param state: The current state. ("dispatcher")
+ If None is given, returns all handlers for the event.
+ Otherwise, returns only handlers that are interested
+ in the specified state.
+ The default is None.
+ """
+ ev_cls = ev.__class__
+ handlers = self.event_handlers.get(ev_cls, [])
if state is None:
return handlers
- dispatchers = lambda x: x.callers[ev.__class__].dispatchers
- return [handler for handler in handlers
- if not dispatchers(handler) or state in dispatchers(handler)]
+ def test(h):
+ states = h.callers[ev_cls].dispatchers
+ if not states:
+ # empty states means all states
+ return True
+ return state in states
+
+ return filter(test, handlers)
def get_observers(self, ev, state):
observers = []
--
1.8.3.1
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel