> Sorry, can you rebase this series for the current git head? done.
YAMAMOTO Takashi > > On Mon, 24 Mar 2014 16:55:41 +0900 > YAMAMOTO Takashi <[email protected]> wrote: > >> Signed-off-by: YAMAMOTO Takashi <[email protected]> >> --- >> ryu/base/app_manager.py | 26 +++++++++++++++++++++----- >> 1 file changed, 21 insertions(+), 5 deletions(-) >> >> diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py >> index 669e58b..6aeb317 100644 >> --- a/ryu/base/app_manager.py >> +++ b/ryu/base/app_manager.py >> @@ -1,4 +1,4 @@ >> -# Copyright (C) 2011, 2012 Nippon Telegraph and Telephone Corporation. >> +# Copyright (C) 2011-2014 Nippon Telegraph and Telephone Corporation. >> # Copyright (C) 2011 Isaku Yamahata <yamahata at valinux co jp> >> # >> # Licensed under the Apache License, Version 2.0 (the "License"); >> @@ -37,6 +37,14 @@ def lookup_service_brick(name): >> return SERVICE_BRICKS.get(name) >> >> >> +def _lookup_service_brick_by_ev_cls(ev_cls): >> + return _lookup_service_brick_by_mod_name(ev_cls.__module__) >> + >> + >> +def _lookup_service_brick_by_mod_name(mod_name): >> + return lookup_service_brick(mod_name.split('.')[-1]) >> + >> + >> def register_app(app): >> assert isinstance(app, RyuApp) >> assert not app.name in SERVICE_BRICKS >> @@ -158,6 +166,16 @@ class RyuApp(object): >> for observers in self.observers.values(): >> observers.pop(name, None) >> >> + def observe_event(self, ev_cls, states=None): >> + brick = _lookup_service_brick_by_ev_cls(ev_cls) >> + if brick is not None: >> + brick.register_observer(ev_cls, self.name, states) >> + >> + def unobserve_event(self, ev_cls): >> + brick = _lookup_service_brick_by_ev_cls(ev_cls) >> + if brick is not None: >> + brick.unregister_observer(ev_cls, self.name) >> + >> def get_handlers(self, ev, state=None): >> handlers = self.event_handlers.get(ev.__class__, []) >> if state is None: >> @@ -323,10 +341,8 @@ class AppManager(object): >> if not hasattr(m, 'observer'): >> continue >> >> - # name is module name of ev_cls >> - name = m.observer.split('.')[-1] >> - if name in SERVICE_BRICKS: >> - brick = SERVICE_BRICKS[name] >> + brick = _lookup_service_brick_by_mod_name(m.observer) >> + if brick: >> brick.register_observer(m.ev_cls, i.name, m.dispatchers) >> >> # allow RyuApp and Event class are in different module >> -- >> 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 > > ------------------------------------------------------------------------------ > 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 ------------------------------------------------------------------------------ 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
