DBus 对象的子对象
我正在尝试编写一个导出用户的 dbus 对象,并在 /path/to/users 创建了我的对象。该对象具有诸如“用户添加”、“用户删除”等信号。
然后我想为用户 a、b 在 /path/to/users/[a, b, c] 处提供对每个用户的访问权限c 将为每个用户提供一些方法。
我的问题是如何“列出”路径 /path/to/users 以返回 a、b、c?
我唯一的选择是从 path.to.users.ListUsers() 返回路径数组,是否有一个我可以继承的标准接口,或者某种形式的内省?
谢谢。
注意。我正在 python 中执行此操作,但我认为问题与语言无关
I'm trying to write a dbus object that exports users and have created my object at /path/to/users. This object has signals such as 'user-added', 'user-removed' etc.
I then want to provide access to each of these users at /path/to/users/[a, b, c] for users a, b and c which will have some methods for each user.
My question though is how do i 'list' the path /path/to/users to return a, b, c?
Is my only option returning an array of paths from path.to.users.ListUsers(), is there a standard interface i can inherit, or some form of introspection?
Thanks.
nb. I'm doing this in python but i think the question is language independent
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
标准 D-Bus Introspectable 接口提供了一种方法内省一个物体; 它返回的数据包括对象列表。
大多数 D-Bus 绑定(包括 dbus-python )都会在服务端为您实现 Introspectable ;因此您的客户端应该能够对
/path/to/users
处的对象调用Introspect
方法来查看存在哪些用户对象。我不知道 dbus-python 是否为这些数据提供了更好的接口。就我个人而言,我会实现一个ListUsers()
方法,该方法返回a{oa{sv}}
— 即对象路径列表,以及有关这些路径的一些属性对象(例如,相当于对每个对象调用Properties.GetAll("uk.co.example.MyService.User")
)。(如果您对未来感兴趣,David Zeuthan 提议标准化像这样的东西。)
The standard D-Bus Introspectable interface provides a method to introspect an object; the data returned by it includes a list of objects.
Most D-Bus bindings, including
dbus-python
, implementIntrospectable
on the service-side for you; so your client should be able to call theIntrospect
method on the object at/path/to/users
to see which user objects exist. I don't know offhand ifdbus-python
provides a nicer interface to this data. Personally, I would implement aListUsers()
method, which returnsa{oa{sv}}
—that is, a list of object paths, along with some properties about those objects (say, the equivalent of callingProperties.GetAll("uk.co.example.MyService.User")
on each object).(If you're interested in the future, David Zeuthan has proposed standardizing something like this.)