Skip to content
Snippets Groups Projects
Commit 522cf98f authored by Arend van Spriel's avatar Arend van Spriel Committed by Thomas Graf
Browse files

python: allow callback function to be a class method


The callback functionality only worked for regular Python
functions. With this patch it also allows the callback
to be a class method (bounded or unbounded) as show in
example below.

class test_class(object):
	def my_callback(self, msg, arg):
		print('handling %s' % str(msg))

s = netlink.core.Socket()
testobj = test_class()
netlink.capi.py_nl_cb_set(cb, netlink.capi.NL_CB_VALID,
			  netlink.capi.NL_CB_CUSTOM,
			  test_class.my_callback, testobj)
netlink.capi.py_nl_cb_err(cb, netlink.capi.NL_CB_CUSTOM,
                          test_class.my_callback, s)

Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
parent 2d55872f
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment