【发布时间】:2012-10-27 08:33:27
【问题描述】:
我是 python 和 dbus 的新手,但是否有通过 dbus-python 的数据绑定(= 一种发送和接收方式)python 类?
我的班级是这样的:
class Item:
def __init__(self, one, two, three, four, five, *more):
self.one= one
self.two= two
self.three= three
self.four= four
self.five= five
self.more= more
其中 more 是一个列表,而一到五个是字符串。我有这些项目的清单:
list_items = []
list_items.append(Item('Test','Test','Test','Test',more))
dbus 部分如下所示:
@dbus.service.method('com.me.test', in_signature='', out_signature='a(sssssav)')
def get_all_items():
return list_items
我的签名是否有错误,或者我必须使用可以编组的不同数据结构(元组?)?
【问题讨论】:
-
您可能会发现this 很有帮助
-
@savruk:我读了这篇文章,并且因为这个链接,我创建了那个 out_signature。但我仍然得到错误。也许我会用列表交换课程。
-
在这种情况下,我会试试这个: 1- 更改 out_signature="a{sav}" 2- 返回项目('Test','Test','Test','Test',more) .__dict__ 而不是 list_items