The definition of register_handler is in pycontext.cc in pyrt.  It's exposed to 
Python via SWIG.

-- Murphy

On Nov 2, 2011, at 10:14 PM, hzy wrote:

> the code problem I have solved after I looked the python books about function.
> 
> but, when I look the codes in the core.py. 
> def register_handler(self, event_name, handler):
>         """\brief Register an event handler.
> 
>         The handler will be called with: handler(event).
>         'event' is a dictionary containing data for the
>          specific event.
> 
>         @param event_name name of the event
>         @param handler handler function
>         """
>         return self.ctxt.register_handler(event_name, handler)
> 
> I can't find the ctxt.register_handler function's definition. I want to see 
> how the register_handler works. which file can I find the definition?
> any ideas?
> 
> 2011/11/2 hzy <yyjianx...@gmail.com>
> The reason why I need to look at the code is that I want to know how does NOX 
> handle the Datapath_join_event.
> I know the gen_datapath_join_callback was invoked by function 
> register_for_datapath_join in core.py.
> 
> I am very interested in the architecture of NOX. I am eager to know how the 
> NOX works. Any information will be appreciated.
> Thanks for advance.
> hzy
> 
> 
> 2011/11/2 hzy <yyjianx...@gmail.com>
> Hi all:
> when I look at the code in nox/src/nox/lib/util.py written in python. I was 
> confused about some codes there. Because I am newbie to python.
> 
> def gen_datapath_join_callback(handler):
>     def f(event):
>         attrs = {}
>         attrs[core.N_BUFFERS] = event.n_buffers
>         attrs[core.N_TABLES] = event.n_tables
>         attrs[core.CAPABILITES] = event.capabilities
>         attrs[core.ACTIONS] = event.actions
>         attrs[core.PORTS] = event.ports
>         for i in range(0, len(attrs[core.PORTS])):
>             port = attrs[core.PORTS][i]
>             config = port['config']
>             state = port['state']
>             attrs[core.PORTS][i]['link']    = (state & 
> openflow.OFPPS_LINK_DOWN) == 0
>             attrs[core.PORTS][i]['enabled'] = (config & 
> openflow.OFPPC_PORT_DOWN) == 0
>             attrs[core.PORTS][i]['flood']   = (config & 
> openflow.OFPPC_NO_FLOOD)  == 0
> 
>         ret = f.cb(event.datapath_id, attrs)
>         if ret == None:
>             return CONTINUE
>         return ret
>     f.cb = handler
>     return f
>  
> Python can define a function in a function really confused me. I do not know 
> how the function f(event) is invoked. and what the f.cb mean.
> Any ideas?
> Thanks forward.
> hzy
> 
> 
> _______________________________________________
> nox-dev mailing list
> nox-dev@noxrepo.org
> http://noxrepo.org/mailman/listinfo/nox-dev

_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev

Reply via email to