| 1 |
dasbus vs pydbus |
| 2 |
================ |
| 3 |
|
| 4 |
The dasbus library used to be based on `pydbus <https://github.com/LEW21/pydbus>`_, but it was |
| 5 |
later reimplemented. We have changed the API and the implementation of the library based on our |
| 6 |
experience with pydbus. However, it should be possible to modify dasbus classes to work the same |
| 7 |
way as pydbus classes. |
| 8 |
|
| 9 |
What is new |
| 10 |
----------- |
| 11 |
|
| 12 |
- Support for asynchronous DBus calls: DBus methods can be called asynchronously. |
| 13 |
|
| 14 |
- Support for Unix file descriptors: It is possible to send or receive Unix file descriptors. |
| 15 |
|
| 16 |
- Mapping DBus errors to exceptions: Use Python exceptions to propagate and handle DBus errors. |
| 17 |
Define your own rules for mapping errors to exceptions and back. See the |
| 18 |
:class:`ErrorMapper <dasbus.error.ErrorMapper>` class |
| 19 |
|
| 20 |
- Support for type hints: Use Python type hints from :mod:`dasbus.typing` to define DBus types. |
| 21 |
|
| 22 |
- Generating XML specifications: Automatically generate XML specifications from Python classes |
| 23 |
with the :func:`dbus_interface <dasbus.server.interface.dbus_interface>` decorator. |
| 24 |
|
| 25 |
- Support for DBus structures: Represent DBus structures (dictionaries of variants) by Python |
| 26 |
objects. See the :class:`DBusData <dasbus.structure.DBusData>` class. |
| 27 |
|
| 28 |
- Support for groups of DBus objects: Use DBus containers from :mod:`dasbus.server.container` |
| 29 |
to publish groups of Python objects. |
| 30 |
|
| 31 |
- Composition over inheritance: The library follows the principle of composition over |
| 32 |
inheritance. It allows to easily change the default behaviour. |
| 33 |
|
| 34 |
- Lazy DBus connections: DBus connections are established on demand. |
| 35 |
|
| 36 |
- Lazy DBus proxies: Attributes of DBus proxies are created on demand. |
| 37 |
|
| 38 |
|
| 39 |
What is different |
| 40 |
----------------- |
| 41 |
|
| 42 |
- No context managers: There are no context managers in dasbus. Context managers and event |
| 43 |
loops don't work very well together. |
| 44 |
|
| 45 |
- No auto-completion: There is no support for automatic completion of DBus names and paths. |
| 46 |
We recommend to work with constants defined by classes from :mod:`dasbus.identifier` |
| 47 |
instead of strings. |
| 48 |
|
| 49 |
- No unpacking of variants: The dasbus library doesn't unpack variants by default. It means |
| 50 |
that values received from DBus match the types declared in the XML specification. Use the |
| 51 |
:func:`get_native <dasbus.typing.get_native>` function to unpack the values. |
| 52 |
|
| 53 |
- Obtaining proxy objects: Call the :meth:`get_proxy <dasbus.connection.MessageBus.get_proxy>` |
| 54 |
method to get a proxy of the specified DBus object. |
| 55 |
|
| 56 |
- No single-interface view: DBus proxies don't support single-interface views. Use the |
| 57 |
:class:`InterfaceProxy <dasbus.client.proxy.InterfaceProxy>` class to access a specific |
| 58 |
interface of a DBus object. |
| 59 |
|
| 60 |
- Higher priority of standard interfaces: If there is a DBus interface in the XML specification |
| 61 |
that redefines a member of a standard interface, the DBus proxy will choose a member of the |
| 62 |
standard interface. Use the :class:`InterfaceProxy <dasbus.client.proxy.InterfaceProxy>` class |
| 63 |
to access a specific interface of a DBus object. |
| 64 |
|
| 65 |
- No support for help: Members of DBus proxies are created lazily, so the build-in ``help`` |
| 66 |
function doesn't return useful information about the DBus interfaces. |
| 67 |
|
| 68 |
- Watching DBus names: Use :class:`a service observer <dasbus.client.observer.DBusObserver>` |
| 69 |
to watch a DBus name. |
| 70 |
|
| 71 |
- Acquiring DBus names: Call the :meth:`register_service <dasbus.connection.MessageBus.register_service>` |
| 72 |
method to acquire a DBus name. |
| 73 |
|
| 74 |
- Providing XML specifications: Use the ``__dbus_xml__`` attribute to provide the XML |
| 75 |
specification of a DBus object. Or you can generate it from the code using the |
| 76 |
:func:`dbus_interface <dasbus.server.interface.dbus_interface>` decorator. |
| 77 |
|
| 78 |
- No support for polkit: There is no support for the DBus service ``org.freedesktop.PolicyKit1``. |
| 79 |
|
| 80 |
What is the same (for now) |
| 81 |
-------------------------- |
| 82 |
|
| 83 |
- No support for other event loops: Dasbus uses GLib as its backend, so it requires to use |
| 84 |
the GLib event loop. However, the GLib part of dasbus is separated from the rest of the code, |
| 85 |
so it shouldn't be too difficult to add support for a different backend. It would be necessary |
| 86 |
to replace :class:`dasbus.typing.Variant` and :class:`dasbus.typing.VariantType` with their |
| 87 |
abstractions and reorganize the code. |
| 88 |
|
| 89 |
- No support for org.freedesktop.DBus.ObjectManager: There is no support for object managers, |
| 90 |
however the :class:`DBus containers <dasbus.server.container.DBusContainer>` could be a good |
| 91 |
starting point. |