diff src/bridge/bridge_constructor/dbus_frontend_template.py @ 1794:b0ed4863dbc7

bridge (D-Bus): fixed handling of profile in kwargs: kwargs are not handled by python D-Bus (i.e. they are not sent through D-Bus). The "profile" and "profile_key" kwargs are often used through SàT with the bridge, this was working so far because they were used for core methods (which have a signature in DBus.py handling profile), or in Libervia browser who ignore profile argument. But if the profile or profile_key was used as a keyword for plugin method outside of Libervia browser, they were ignored, this commit fix this by adding them to the args list.
author Goffi <goffi@goffi.org>
date Wed, 13 Jan 2016 18:44:32 +0100
parents d17772b0fe22
children 05a5a125a238
line wrap: on
line diff
--- a/src/bridge/bridge_constructor/dbus_frontend_template.py	Wed Jan 13 18:15:20 2016 +0100
+++ b/src/bridge/bridge_constructor/dbus_frontend_template.py	Wed Jan 13 18:44:32 2016 +0100
@@ -100,15 +100,25 @@
                 #   - or if the last two arguments are callable
 
                 async = False
+                args = list(args)
 
                 if kwargs:
                     if 'callback' in kwargs:
                         async = True
                         _callback = kwargs.pop('callback')
                         _errback = kwargs.pop('errback', lambda failure: log.error(unicode(failure)))
+                    try:
+                        args.append(kwargs.pop('profile'))
+                    except KeyError:
+                        try:
+                            args.append(kwargs.pop('profile_key'))
+                        except KeyError:
+                            pass
+                    # at this point, kwargs should be empty
+                    if kwargs:
+                        log.warnings(u"unexpected keyword arguments, they will be ignored: {}".format(kwargs))
                 elif len(args) >= 2 and callable(args[-1]) and callable(args[-2]):
                     async = True
-                    args = list(args)
                     _errback = args.pop()
                     _callback = args.pop()