[sugar] DBus-python and signals with changing types

Benjamin M. Schwartz bmschwar
Sun Feb 3 15:42:38 EST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I would like to create a simple D-Bus signal of the form

    @dbus.service.signal(dbus_interface=self.IFACE)
    def send(self, message):
        return

However, I do not know the type signature of "message" ahead of time.  I also do
not know whether the user wants byte_arrays=True, etc.  I would like to set
these parameters each time send() is called.  How can I do this?

The only way that I have thought of is to do:

def send(self, message, signature=None, byte_arrays=True):
    self._sig = signature
    self._ba = byte_arrays
    self._actual_send(message)

@dbus.service.signal(dbus_interface=self.IFACE, signature=self._sig,
byte_arrays=self._ba)
def _actual_send(self, message):
    return

Will this work?  Is it threadsafe (I think not)? Is there a better way?

- --Ben
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHpic9UJT6e6HFtqQRAnHjAJ9u4TwZ2kYN7+tYwvw10gMmFJE/OQCeNXjg
7LDPkt8lU4jG1o/ZBgk9vE4=
=Vzmh
-----END PGP SIGNATURE-----



More information about the Sugar-devel mailing list