according to FUJITA Tomonori, these are internal methods.
prefix them with '_' to make it clear and avoid further abuses.

Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
 ryu/app/gre_tunnel.py        |  4 +++-
 ryu/base/app_manager.py      | 16 ++++++++--------
 ryu/controller/controller.py |  2 +-
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/ryu/app/gre_tunnel.py b/ryu/app/gre_tunnel.py
index 29e8cab..01f9cd7 100644
--- a/ryu/app/gre_tunnel.py
+++ b/ryu/app/gre_tunnel.py
@@ -394,7 +394,9 @@ class GRETunnel(app_manager.RyuApp):
         self.tunnels = kwargs['tunnels']
 
         self.port_set = PortSet(**kwargs)
-        map(lambda ev_cls: self.port_set.register_observer(ev_cls, self.name),
+
+        # XXX should not call _register_observer directly
+        map(lambda ev_cls: self.port_set._register_observer(ev_cls, self.name),
             [dpset.EventDP, PortSet.EventTunnelKeyDel, PortSet.EventVMPort,
             PortSet.EventTunnelPort, ofp_event.EventOFPPacketIn])
 
diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py
index a3abc85..5ceaf4f 100644
--- a/ryu/base/app_manager.py
+++ b/ryu/base/app_manager.py
@@ -71,14 +71,14 @@ class RyuApp(object):
         self.event_handlers.setdefault(ev_cls, [])
         self.event_handlers[ev_cls].append(handler)
 
-    def register_observer(self, ev_cls, name, states=None):
+    def _register_observer(self, ev_cls, name, states=None):
         states = states or []
         self.observers.setdefault(ev_cls, {})[name] = states
 
-    def get_handlers(self, ev):
+    def _get_handlers(self, ev):
         return self.event_handlers.get(ev.__class__, [])
 
-    def get_observers(self, ev, state):
+    def _get_observers(self, ev, state):
         observers = []
         for k, v in self.observers.get(ev.__class__, {}).iteritems():
             if not state or not v or state in v:
@@ -98,7 +98,7 @@ class RyuApp(object):
     def _event_loop(self):
         while True:
             ev = self.events.get()
-            handlers = self.get_handlers(ev)
+            handlers = self._get_handlers(ev)
             for handler in handlers:
                 handler(ev)
 
@@ -115,7 +115,7 @@ class RyuApp(object):
                       (self.name, name, ev.__class__.__name__))
 
     def send_event_to_observers(self, ev, state=None):
-        for observer in self.get_observers(ev, state):
+        for observer in self._get_observers(ev, state):
             self.send_event(observer, ev)
 
     def close(self):
@@ -200,14 +200,14 @@ class AppManager(object):
                     name = m.observer.split('.')[-1]
                     if name in SERVICE_BRICKS:
                         brick = SERVICE_BRICKS[name]
-                        brick.register_observer(m.ev_cls, i.name,
-                                                m.dispatchers)
+                        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)
+                            brick._register_observer(m.ev_cls, i.name)
 
         for brick, i in SERVICE_BRICKS.items():
             LOG.debug("BRICK %s" % brick)
diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py
index c753f01..4a64fb6 100644
--- a/ryu/controller/controller.py
+++ b/ryu/controller/controller.py
@@ -172,7 +172,7 @@ class Datapath(object):
                 ev = ofp_event.ofp_msg_to_ev(msg)
                 self.ofp_brick.send_event_to_observers(ev, self.state)
 
-                handlers = self.ofp_brick.get_handlers(ev)
+                handlers = self.ofp_brick._get_handlers(ev)
                 for handler in handlers:
                     if self.state in handler.dispatchers:
                         handler(ev)
-- 
1.8.0.1


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to