[sugar] DBus-python and signals with changing types

Benjamin M. Schwartz bmschwar at fas.harvard.edu
Mon Feb 4 09:51:32 EST 2008


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

John (J5) Palmieri wrote:
> Perhaps you are going about it the wrong way. 
Indeed.

> First of all decorators
> are executed when the method is parsed, way before the class is
> instantiated so you will get an error there.
True.

> Also by sending different
> signatures you are going to be giving back false introspect information
> and basically making it harder for non-dynamically bound languages to
> communicate with you.  Also why would you make an external app specify
> byte array or not?
I am writing a library for Python Activity developers.  I would like to provide
the necessary plumbing to ensure that Activities can share a unified data model
in the face of arbitrary network problems, including unexpected group splits and
merges.  Thus, I am writing code that talks over D-Bus tubes, but is sending
messages whose type is controlled by whoever is using the library.  Since I do
not know that developer's types or preferences ahead of time, I would like to
allow them to control the types, and also message parameters (such as
byte_arrays and utf8_strings).

After talking to Simon McVittie, it seems that I can come close by setting all
my signatures to variant.  The user may then either trust the introspection, or
set dbus types explicitly by constructing messages in this style:

dbus.Struct(('a', 42), signature='su')

This doesn't solve the byte_arrays problem, but that is less important.

Something that would be nice, in the future, is support for programmatically
generated interfaces.  For example, Java now has support for parameterized
interfaces.  Python is much more dynamic, but there is no support in dbus-python
for setting the interface at constructor-time.  That would be an improvement,
though still not as Pythonic as setting the types on each call.

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

iD8DBQFHpyZ0UJT6e6HFtqQRAi5BAJwK6PDXcXnfhr7cyZe7XJptBdWX8wCfVFQx
2//lakThgxl4LkGTNp3752Q=
=g6F6
-----END PGP SIGNATURE-----


More information about the Sugar mailing list