dbus-python 0.79.93 (= 0.80rc3) release candidate

Luigi Paioro luigi at lambrate.inaf.it
Wed Dec 20 07:35:50 PST 2006


> I was under the impression that process_introspection_data would only be
> useful internally. What do you use it for?

Simply I use it to get all the interfaces and methods for each object I 
have.

I try to explain in detail what I do in my code.

I put on the bus objects which have methods and attributes. For each of 
them I export the general object interface and the 
org.freedesktop.DBus.Properties interface with the Get and Set method in 
order to handle the object attributes. To know all the object 
attributes, I also export a org.freedesktop.DBus.Properties.GetAll 
method which returns a dictionary with all the object attributes I want 
to handle.

Then I've created a FriendlyInterface class which extends dbus.Interface 
class. Such class does something like what you example here below for 
the full introspection data. Using the process_introspection_data 
function I get a list of the interfaces and methods and I provide the 
method access putting it directly into the FriendlyInterface.__dict__. 
So I can view them through the python console typing TAB. I do the same 
thing getting the attribute list with 
org.freedesktop.DBus.Properties.GetAll: I put them in the __dict__ and I 
exploit the  __getattr__ and __setattr__ to directly access them through 
  org.freedesktop.DBus.Properties.Get and 
org.freedesktop.DBus.Properties.Set exported method.

It's pretty tangled but it works.


> The reason for the name change was that the libxml2 and expat versions
> briefly existed in parallel during development. I didn't think the
> introspect_parser was meant to be public API, hence the new name.
> (Please note that it's slightly incompatible too - the old version
> wanted unicode input, the new one wants UTF-8 str objects, and
> dbus.proxies has been changed accordingly. I can make it backwards-compatibly
> accept Unicode if you want.)

It doesn't matter in my case, thanks...

> I can move it back and make it "official" public API if you need it, but
> I'm concerned that it only gives you a small subset of what's in the
> introspection - no 'out' argument signatures, no annotations and no
> list of sub-nodes.

For the time being it's not a problem. My software is still a prototype 
under development... I can change it many times...

> If the full introspection data would be useful, it seems a better API
> to provide it via properties on the proxies, something like:
> 
> 	>>> proxy = dbus.SessionBus().get_object('com.example.HelloWorld', '/')
> 	>>> proxy.dbus_interfaces
> 	('com.example.HelloWorld',)
> 	>>> proxy.dbus_methods
> 	('com.example.HelloWorld.SayHelloTo',)
> 	>>> proxy.dbus_signals
> 	('com.example.HelloWorld.Greeting',)
> 	>>> iface = dbus.Interface(proxy, 'com.example.HelloWorld')
> 	>>> # method SayHelloTo(s: person) -> nothing
> 	>>> iface.dbus_methods
> 	('SayHelloTo',)
> 	>>> iface.SayHelloTo.in_signature
> 	dbus.Signature('s')
> 	>>> iface.SayHelloTo.out_signature
> 	dbus.Signature('')
> 	>>> iface.SayHelloTo.annotations
> 	{'com.example.Annotated': 'yes'}
> 	>>> iface.dbus_signals
> 	>>> # signal Greeting(s: message)
> 	('Greeting',)
> 	>>> iface.Greeting.signature
> 	dbus.Signature('s')
> 	>>> iface.Greeting.annotations
> 	{'com.example.Annotated': 'yes'}
> 	>>> iface.dbus_nodes
> 	('/SubObject', '/OtherObject')
> 

This would be very nice! ^_^

Luigi




More information about the dbus mailing list