diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-08-01 18:34:38 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-08-01 18:34:38 +0100 |
commit | 159319390404ed58406dba5a42d931740660af78 (patch) | |
tree | 5263468533c02b1b83b3f7b60659048f4b152efc | |
parent | 5aef31b429ac0c14312265e166aeeeda91b3f8ac (diff) | |
download | dbus-python-159319390404ed58406dba5a42d931740660af78.tar.gz |
Fix introspection on objects with more than one connection or more than one object path (bugs.fd.o #11794)
-rw-r--r-- | dbus/service.py | 12 | ||||
-rwxr-xr-x | test/test-client.py | 11 | ||||
-rwxr-xr-x | test/test-service.py | 8 |
3 files changed, 25 insertions, 6 deletions
diff --git a/dbus/service.py b/dbus/service.py index 21f0da8..8ffec3e 100644 --- a/dbus/service.py +++ b/dbus/service.py @@ -33,7 +33,7 @@ except ImportError: import _dbus_bindings from dbus import SessionBus, Signature, Struct, validate_bus_name, \ - validate_object_path + validate_object_path, INTROSPECTABLE_IFACE from dbus.decorators import method, signal from dbus.exceptions import DBusException, \ NameExistsException, \ @@ -709,13 +709,14 @@ class Object(Interface): # send error reply _method_reply_error(connection, message, exception) - @method('org.freedesktop.DBus.Introspectable', in_signature='', out_signature='s') - def Introspect(self): + @method(INTROSPECTABLE_IFACE, in_signature='', out_signature='s', + path_keyword='object_path', connection_keyword='connection') + def Introspect(self, object_path, connection): """Return a string of XML encoding this object's supported interfaces, methods and signals. """ reflection_data = _dbus_bindings.DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE - reflection_data += '<node name="%s">\n' % (self._object_path) + reflection_data += '<node name="%s">\n' % object_path interfaces = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__] for (name, funcs) in interfaces.iteritems(): @@ -729,8 +730,7 @@ class Object(Interface): reflection_data += ' </interface>\n' - for name in self._connection.list_exported_child_objects( - self._object_path): + for name in connection.list_exported_child_objects(object_path): reflection_data += ' <node name="%s"/>\n' % name reflection_data += '</node>\n' diff --git a/test/test-client.py b/test/test-client.py index b600d9d..050ed46 100755 --- a/test/test-client.py +++ b/test/test-client.py @@ -118,6 +118,17 @@ class TestDBusBindings(unittest.TestCase): print "Introspection test passed" self.assert_(True) + def testMultiPathIntrospection(self): + # test introspection on an object exported in multiple places + # https://bugs.freedesktop.org/show_bug.cgi?id=11794 + remote_object = self.bus.get_object(NAME, OBJECT + '/Multi1') + remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable") + remote_object = self.bus.get_object(NAME, OBJECT + '/Multi2') + remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable") + remote_object = self.bus.get_object(NAME, OBJECT + '/Multi2/3') + remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable") + self.assert_(True) + def testPythonTypes(self): #test sending python types and getting them back print "\n********* Testing Python Types ***********" diff --git a/test/test-service.py b/test/test-service.py index ef4efe2..4488eb1 100755 --- a/test/test-service.py +++ b/test/test-service.py @@ -111,10 +111,18 @@ class Fallback(dbus.service.FallbackObject): logger.info('Emitting %s from abs %r', signal, path) sig('I am', 'a deprecated fallback', path=path) +class MultiPathObject(dbus.service.Object): + SUPPORTS_MULTIPLE_OBJECT_PATHS = True + class TestObject(dbus.service.Object, TestInterface): def __init__(self, bus_name, object_path=OBJECT): dbus.service.Object.__init__(self, bus_name, object_path) self._removable = RemovableObject() + self._multi = MultiPathObject(bus_name, object_path + '/Multi1') + self._multi.add_to_connection(bus_name.get_bus(), + object_path + '/Multi2') + self._multi.add_to_connection(bus_name.get_bus(), + object_path + '/Multi2/3') """ Echo whatever is sent """ |