[pyatspi2] Enable Re-entrancy within pyatspi.



commit 9cf559ba6e707a955806d35baeb817300948bb7d
Author: Mark Doffman <mark doffman codethink co uk>
Date:   Tue Feb 2 16:54:12 2010 -0800

    Enable Re-entrancy within pyatspi.

 pyatspi/busutils/bus.py |    6 +++---
 pyatspi/cache.py        |   12 +++++++-----
 pyatspi/exceptions.py   |    8 +++++++-
 pyatspi/factory.py      |    2 +-
 4 files changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/pyatspi/busutils/bus.py b/pyatspi/busutils/bus.py
index 5a84d6a..cd919fc 100644
--- a/pyatspi/busutils/bus.py
+++ b/pyatspi/busutils/bus.py
@@ -82,9 +82,9 @@ class _AccessibilityBus (_bus.BusConnection):
 
 		return _bus.BusConnection.add_signal_receiver (self, wrapper, *args, **kwargs)
 
-	def get_object (self, name, path):
-		return _connection.ProxyObject (self, name, path, introspect=False)
-		#return AccessibilityProxy (self, name, path, introspect=False)
+	def get_object (self, name, path, introspect=False):
+		#return _connection.ProxyObject (self, name, path, introspect=False)
+		return AccessibilityProxy (self, name, path, introspect)
 
 
 class AsyncAccessibilityBus (_AccessibilityBus):
diff --git a/pyatspi/cache.py b/pyatspi/cache.py
index b6c2353..ebbbb80 100644
--- a/pyatspi/cache.py
+++ b/pyatspi/cache.py
@@ -95,13 +95,13 @@ class DesktopCacheManager (object):
                                         sender_keyword="sender",
                                         path_keyword="path")
 
-                obj     = bus.get_object(ATSPI_REGISTRY_NAME, ATSPI_ROOT_PATH)
+                obj     = bus.get_object(ATSPI_REGISTRY_NAME, ATSPI_ROOT_PATH, introspect=False)
                 desktop = dbus.Interface(obj, ATSPI_ACCESSIBLE)
                 apps    = desktop.GetChildren()
 
                 #TODO This is ugly. Perhaps the desktop object should implement the
                 #     cache interface also?
-                bus_object = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
+                bus_object = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus", introspect=False)
                 self._unique_name = bus_object.GetNameOwner (ATSPI_REGISTRY_NAME)
                 self._cache[(self._unique_name, ATSPI_ROOT_PATH)] = \
                         _CacheData ( 
@@ -113,7 +113,7 @@ class DesktopCacheManager (object):
                                        "main",                                  #Name
                                        ROLE_INVALID,                            #Role
                                        "",                                      #Description
-                                       []                                       #State
+                                       [0,0]                                    #State
                                      )
                                    )
 
@@ -154,12 +154,14 @@ class ApplicationCacheManager (object):
                 connection - DBus connection.
                 busName    - Name of DBus connection where cache interface resides.
                 """
-                bus = SyncAccessibilityBus()
+                # It is important that this bus is async as registered signals may
+                # come from orca itself.
+                bus = AsyncAccessibilityBus()
 
                 self._cache = cache
 		self._bus_name = bus_name
 
-                cache_obj = bus.get_object (bus_name, _ATSPI_CACHE_PATH)
+                cache_obj = bus.get_object (bus_name, _ATSPI_CACHE_PATH, introspect=False)
                 cache_itf = dbus.Interface (cache_obj, _ATSPI_CACHE_INTERFACE)
                 self._add_objects(cache_itf.GetItems())
 
diff --git a/pyatspi/exceptions.py b/pyatspi/exceptions.py
index 5714aae..2120aa2 100644
--- a/pyatspi/exceptions.py
+++ b/pyatspi/exceptions.py
@@ -16,7 +16,13 @@
 #------------------------------------------------------------------------------
 
 class AccessibleObjectNoLongerExists(Exception):
-        def __init__ (self): self._message = ""
+
+        def __init__ (self, message=None):
+                if message:
+                        self._message = message
+                else:
+                        self._message = ""
+
         def _get_message(self, message): return self._message
         def _set_message(self, message): self._message = message
         message = property(_get_message, _set_message)
diff --git a/pyatspi/factory.py b/pyatspi/factory.py
index 621eaf2..9b31b15 100644
--- a/pyatspi/factory.py
+++ b/pyatspi/factory.py
@@ -74,7 +74,7 @@ class AccessibleFactory (object):
 			return None
 
                 if dbus_object == None:
-                        dbus_object = self._connection.get_object (name, path)
+                        dbus_object = self._connection.get_object (name, path, introspect=False)
         
                 return self._interfaces[itf] (self._cache, self, name, path, dbus_object)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]