Instantiate dbus system bus where it works
authorEnrico Zini <enrico@enricozini.org>
Sun, 14 Jun 2009 05:06:14 +0000 (13:06 +0800)
committerEnrico Zini <enrico@enricozini.org>
Sun, 14 Jun 2009 05:06:14 +0000 (13:06 +0800)
For some reason, instantiating it in Registry makes it not find the main loop

src/zavai
zavai/registry.py

index e86977a7b5b77022252d26880dd8c9199950ea54..3adaa562c57118f3e2fe529bf7f82b2f5958daf0 100755 (executable)
--- a/src/zavai
+++ b/src/zavai
@@ -55,12 +55,13 @@ conf = zavai.read_config(nick="zavai")
 
 # Set up dbus
 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+dbus_system_bus = dbus.SystemBus()
 
 # Set up zavai
 registry = zavai.Registry()
 
 # Register main factories
-registry.register("dbus.system_bus", dbus.SystemBus)
+registry.register("dbus.system_bus", lambda *args, **kw: dbus_system_bus)
 registry.register("conf", lambda *args, **kw: conf)
 registry.register("app", zavai.Zavai)
 registry.register("menu", zavai.Menu)
index 1694196bae6eaa8ddcf2aff731ea1e1f985f7461..304ec8e2a35a9b3a5de28946fc7e64e4087d9c0a 100644 (file)
@@ -42,8 +42,8 @@ class Registry(object):
         res = self.objects.get(name, None)
         if res is None:
             fac = self.factories.get(name, None)
+            root = name
             if fac is None:
-                root = name
                 while True:
                     pos = root.rfind(".")
                     if pos == -1: break
@@ -51,6 +51,7 @@ class Registry(object):
                     fac = self.factories.get(root, None)
                 if fac is None:
                     return None
+            zavai.info("Instantiating", name, "with factory", root)
             res = fac(self, name)
             if res is not None:
                 self.objects[name] = res