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

Reply via email to