Proposed change in python binding's signal handlers

John (J5) Palmieri johnp at redhat.com
Thu Feb 3 14:42:57 PST 2005


I want to get input on an idea I had for revamping how we do signal
handlers as I am not sure the reason why we do them the way we do now.
Basically the signature for signal handlers are not very descriptive and
cause questions like "how do I extract arguments from a signal?".
Currently a signal handler function would look like this:

def foobar (interface, signal_name, service, path, message):
        args = message.get_args_list()
        #get the arguments in the order they were sent
        album_name = args[0]
        band_name = args[1]
	#or (album_name, band_name) = args
	print band_name + ": " + album_name

Why not do something more like this:

class Source:
	def __init__(self, interface, signal_name, 
                     service, path, message):
		self.interface = interface
		self.signal_name = signal_name
		self.service = service
		self.path = path
		self.message = message

def foobar (source, album_name, band_name):
	print band_name + ": " + album_name

I think this helps signal handlers be a bit more self documenting as the
signature for the handler would be the same (excluding source) as the D-
BUS signal's signature.  It also feels more natural.  Anyway if no one
objects I will go ahead and implement this.

-- 
John (J5) Palmieri
Associate Software Engineer
Desktop Group
Red Hat, Inc.
Blog: http://martianrock.com



More information about the dbus mailing list