From 5afe4265eaa30afa7d93eb1550839c56360abeda Mon Sep 17 00:00:00 2001 From: Seth Nickell Date: Mon, 12 Jul 2004 06:29:00 +0000 Subject: 2004-07-12 Seth Nickell * python/dbus.py: Add message argument to the default object_method_handler function. * python/dbus_bindings.pyx.in: Automatically return NIL when passed an empty list (we can't pass back a list since lists are typed and we don't have any idea what type the the client intended the list to be... :-( ) --- python/dbus.py | 2 +- python/dbus_bindings.pyx.in | 28 ++++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'python') diff --git a/python/dbus.py b/python/dbus.py index e53bf237..55c61235 100644 --- a/python/dbus.py +++ b/python/dbus.py @@ -337,7 +337,7 @@ class ObjectTree: message = dbus_bindings.Signal(object_path, interface, signal_name) self._connection.send(message) - def object_method_called(self, relative_path, method_name, argument_list): + def object_method_called(self, message, relative_path, method_name, argument_list): """Override this method. Called with, object_path, the relative path of the object under the base_path, the name of the method invoked, and a list of arguments """ diff --git a/python/dbus_bindings.pyx.in b/python/dbus_bindings.pyx.in index de90603b..6703f7d3 100644 --- a/python/dbus_bindings.pyx.in +++ b/python/dbus_bindings.pyx.in @@ -614,19 +614,23 @@ cdef class MessageIter: elif value_type == dict: retval = self.append_dict(value) elif value_type == list: - if (len(value) == 0): - raise TypeError, "Empty lists are currently not supported, return None instead" - list_type = type(value[0]) - if list_type == str: - self.append_string_array(value) - elif list_type == int: - self.append_int32_array(value) - elif list_type == float: - self.append_double_array(value) - elif isinstance(value[0], ObjectPath): - self.append_object_path_array(value) + if len(value) == 0: + # Empty lists are currently not supported, returning None instead + retval = self.append(None) else: - raise TypeError, "List of unknown type '%s'" % (list_type) + list_type = type(value[0]) + if list_type == str: + self.append_string_array(value) + elif list_type == int: + self.append_int32_array(value) + elif list_type == float: + self.append_double_array(value) + elif isinstance(value[0], ObjectPath): + self.append_object_path_array(value) + else: + raise TypeError, "List of unknown type '%s'" % (list_type) + elif value_type == None.__class__: + retval = self.append_nil() elif isinstance(value, ObjectPath): retval = self.append_object_path(value) else: -- cgit