API changes in dbus-python 0.80

Author: Simon McVittie
Contact: simon.mcvittie@collabora.co.uk
Organization: Collabora Ltd
Date: 2006-11-23

Type changes

Calling conventions


Main loops

Main loop handling is different - instead of the use_default_mainloop keyword argument to Bus and subclasses, there's now mainloop which takes an instance of dbus.mainloop.NativeMainLoop.

Alternatively, you can set a default main loop by calling dbus.set_default_main_loop() and passing it a NativeMainLoop, or by passing set_as_default=True to the factory function from which you obtained the native main loop.

The plan is that in a future version of dbus-python there will be an abstract base class dbus.mainloop.MainLoop (or something); when it's added, instances of its subclasses will be accepted wherever a NativeMainLoop instance is now. This will let you wrap main loops using a Python API. This will be used to implement SimpleMainLoop (a pure-Python main loop which can only do D-Bus) and a Twisted main-loop wrapper.

The only working mainloop implementation is (still) GLib; you can get a NativeMainLoop instance by:

from dbus.mainloop.glib import DBusGMainLoop
my_native_main_loop = DBusGMainLoop(set_as_default=True)

The above is how the highly magical dbus.glib module is now implemented. At some point dbus.glib will be deprecated, since it's non-obvious, and pychecker will usually complain if you use it correctly!

At the moment the GLib main loop always uses the default main context; python-gobject will probably need to add some extra API before we can allow other main-contexts to be used.