Proposed change in python binding's signal handlers

Seth Nickell snickell at gmail.com
Thu Feb 3 16:05:02 PST 2005


Hey John,

I never finished the signal handlers, so what's there is definitely
"just enough to make them work", not supposed to be a nice API or
anything ;-) Seems like this would be a major change for the better.

-Seth


On Thu, 03 Feb 2005 17:42:57 -0500, John (J5) Palmieri <johnp at redhat.com> wrote:
> 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
> 
> --
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus
> 
>


More information about the dbus mailing list