Ok I had to learn this the hard way since you said it is just going to be
more...
Anyhow looks fine for me
On Tue, Feb 7, 2012 at 10:12 PM, Siegfried Gevatter rai...@ubuntu.comwrote:
Siegfried Gevatter has proposed merging lp:~rainct/zeitgeist/922620 into
lp:zeitgeist.
Requested reviews:
Zeitgeist Framework Team (zeitgeist)
Related bugs:
Bug #922620 in Zeitgeist Framework: Fix failing test cases:
testBlacklistSignals and testDataSourceSignals
https://bugs.launchpad.net/zeitgeist/+bug/922620
For more details, see:
https://code.launchpad.net/~rainct/zeitgeist/922620/+merge/91920
--
https://code.launchpad.net/~rainct/zeitgeist/922620/+merge/91920
Your team Zeitgeist Framework Team is requested to review the proposed
merge of lp:~rainct/zeitgeist/922620 into lp:zeitgeist.
=== modified file 'python/client.py'
--- python/client.py2011-10-29 13:31:12 +
+++ python/client.py2012-02-07 21:11:18 +
@@ -40,6 +40,15 @@
log = logging.getLogger(zeitgeist.client)
+# This is here so testutils.py can override it with a private bus
connection
+global session_bus
+session_bus = dbus.SessionBus()
+def get_bus():
+ return session_bus
+def _set_bus(bus):
+ global session_bus
+ session_bus = bus
+
class _DBusInterface(object):
Wrapper around dbus.Interface adding convenience methods.
@@ -47,7 +56,6 @@
# that here because otherwise all instances would share their state.
_disconnect_callbacks = None
_reconnect_callbacks = None
- _generic_callbacks = None
@staticmethod
def get_members(introspection_xml):
@@ -69,8 +77,9 @@
def reconnect(self):
if not self._reconnect_when_needed:
return
- self.__proxy = dbus.SessionBus().get_object(
- self.__iface.requested_bus_name,
self.__object_path)
+ self.__proxy = get_bus().get_object(
+ self.__iface.requested_bus_name,
self.__object_path,
+ follow_name_owner_changes=True)
self.__iface = dbus.Interface(self.__proxy,
self.__interface_name)
self._load_introspection_data()
@@ -131,8 +140,7 @@
self.reconnect()
if signal not in self.__signals:
raise TypeError(Unknown signal name: %s % signal)
- self._generic_callbacks.add((signal, callback))
- self.__proxy.connect_to_signal(
+ return self.__proxy.connect_to_signal(
signal,
callback,
dbus_interface=self.__interface_name,
@@ -169,7 +177,6 @@
self._disconnect_callbacks = set()
self._reconnect_callbacks = set()
- self._generic_callbacks = set()
# Listen to (dis)connection notifications, for connect_exit
and connect_join
def name_owner_changed(connection_name):
@@ -181,15 +188,9 @@
return
self.reconnect()
callbacks = self._reconnect_callbacks
- for signal, callback in
self._generic_callbacks:
- try:
- self.connect(signal,
callback)
- except TypeError:
- log.exception(Failed to
reconnect to signal \%s\
- after engine
disconnection. % signal)
for callback in callbacks:
callback()
-
dbus.SessionBus().watch_name_owner(self.__iface.requested_bus_name,
+ get_bus().watch_name_owner(self.__iface.requested_bus_name,
name_owner_changed)
class ZeitgeistDBusInterface(object):
@@ -233,7 +234,8 @@
if not name in cls.__shared_state[extension_interfaces]:
interface_name = org.gnome.zeitgeist.%s % name
object_path = /org/gnome/zeitgeist/%s % path
- proxy = dbus.SessionBus().get_object(busname,
object_path)
+ proxy = get_bus().get_object(busname, object_path,
+ follow_name_owner_changes=True)
iface = _DBusInterface(proxy, interface_name,
object_path)
iface.BUS_NAME = busname
iface.INTERFACE_NAME = interface_name
@@ -244,8 +246,8 @@
def __init__(self, reconnect=True):
if not dbus_interface in self.__shared_state:
try:
- proxy =
dbus.SessionBus().get_object(self.BUS_NAME,
- self.OBJECT_PATH