dbus-python: use home-made object as argument
Zhang Sen
zh.jesse at gmail.com
Tue Jul 14 02:45:47 PDT 2009
Hi,
Can I use a custom object as the argument of dbus call, in python?
Something like,
On the caller's side,
----------
> Class Container:
> def __init__(self, a, b, c):
> self.a = a
> self.b = b
> self.c = c
>
> proxy = bus.get_object(...)
> proxy.foo(Container(1, 2, 3))
----------
And to export the method on the other side,
----------
> @dbus.service.method(dbus_interface=my_interface,
> in_signature="a(uuu)", out_signature="")
> def foo(self, value):
----------
No matter what I put in 'in_signature', I got the error 'Don't know how
which D-Bus type to use to encode type "instance"'.
> ERROR:dbus.connection:Unable to set arguments
> (<__main__.NumberBoxModel instance at 0x18c57e8>,) according to
> signature None:
> <type 'exceptions.TypeError'>: Don't know how which D-Bus type to use
> to encode type "instance"
> Traceback (most recent call last):
> [...]
> File "/usr/lib64/python2.6/site-packages/dbus/proxies.py", line 140,
> in __call__
> **keywords)
> File "/usr/lib/python2.6/site-packages/dbus/connection.py", line
> 620, in call_blocking
> message.append(signature=signature, *args)
> TypeError: Don't know how which D-Bus type to use to encode type
> "instance"
It's dbus-1.2.4 here. (You see the error message even has a typo).
How should I write in_signature, or am I actually thinking the right
way? Thanks.
-zhang
More information about the dbus
mailing list