Oops. I sent out the old patch Here is the correct one. Sorry for confusion.
>From 2bbcfa6b6be4b47859e387ddb940f7291add149a Mon Sep 17 00:00:00 2001 Message-Id: <2bbcfa6b6be4b47859e387ddb940f7291add149a.1365050096.git.yamah...@valinux.co.jp> In-Reply-To: <[email protected]> References: <[email protected]> From: Isaku Yamahata <[email protected]> Date: Thu, 4 Apr 2013 11:33:53 +0900 Subject: [PATCH 03/28] base/app_manager.py: sort out registering bricks When registering RyuApps to observers with _EVENTS, it should applied to @set_ev_cls methods, and dispatchers should be honored. Signed-off-by: Isaku Yamahata <[email protected]> --- ryu/base/app_manager.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py index f285322..ab6175a 100644 --- a/ryu/base/app_manager.py +++ b/ryu/base/app_manager.py @@ -200,19 +200,20 @@ class AppManager(object): for i in SERVICE_BRICKS.values(): for _k, m in inspect.getmembers(i, inspect.ismethod): - if hasattr(m, 'observer'): - # name is module name of ev_cls - name = m.observer.split('.')[-1] - if name in SERVICE_BRICKS: - brick = SERVICE_BRICKS[name] - brick.register_observer(m.ev_cls, i.name, - m.dispatchers) + 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.register_observer(m.ev_cls, i.name, m.dispatchers) # allow RyuApp and Event class are in different module - if hasattr(m, 'ev_cls'): - for brick in SERVICE_BRICKS.itervalues(): - if m.ev_cls in brick._EVENTS: - brick.register_observer(m.ev_cls, i.name) + for brick in SERVICE_BRICKS.itervalues(): + if m.ev_cls in brick._EVENTS: + brick.register_observer(m.ev_cls, i.name, + m.dispatchers) for brick, i in SERVICE_BRICKS.items(): LOG.debug("BRICK %s" % brick) -- 1.7.10.4 On Thu, Apr 04, 2013 at 12:28:03PM +0900, Isaku Yamahata wrote: > When registering RyuApps to observers with _EVENTS, > it should applied to @set_ev_cls methods, and dispatchers should be > honored. > > Signed-off-by: Isaku Yamahata <[email protected]> > --- > ryu/base/app_manager.py | 23 ++++++++++++----------- > 1 file changed, 12 insertions(+), 11 deletions(-) > > diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py > index f285322..3f46dab 100644 > --- a/ryu/base/app_manager.py > +++ b/ryu/base/app_manager.py > @@ -200,19 +200,20 @@ class AppManager(object): > > for i in SERVICE_BRICKS.values(): > for _k, m in inspect.getmembers(i, inspect.ismethod): > - if hasattr(m, 'observer'): > - # name is module name of ev_cls > - name = m.observer.split('.')[-1] > - if name in SERVICE_BRICKS: > - brick = SERVICE_BRICKS[name] > - brick.register_observer(m.ev_cls, i.name, > - m.dispatchers) > + 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.register_observer(m.ev_cls, i.name, m.dispatchers) > > # allow RyuApp and Event class are in different module > - if hasattr(m, 'ev_cls'): > - for brick in SERVICE_BRICKS.itervalues(): > - if m.ev_cls in brick._EVENTS: > - brick.register_observer(m.ev_cls, i.name) > + for brick in SERVICE_BRICKS.itervalues(): > + if m.ev_cls in brick._EVENTS: > + brick.register_observer(m.ev_cls, i.name, > + m.disptachers) > > for brick, i in SERVICE_BRICKS.items(): > LOG.debug("BRICK %s" % brick) > -- > 1.7.10.4 > -- yamahata ------------------------------------------------------------------------------ Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
