Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
1793:f39ca2832774 | 1794:b0ed4863dbc7 |
---|---|
98 # We first check if we have an async call. We detect this in two ways: | 98 # We first check if we have an async call. We detect this in two ways: |
99 # - if we have the 'callback' and 'errback' keyword arguments | 99 # - if we have the 'callback' and 'errback' keyword arguments |
100 # - or if the last two arguments are callable | 100 # - or if the last two arguments are callable |
101 | 101 |
102 async = False | 102 async = False |
103 args = list(args) | |
103 | 104 |
104 if kwargs: | 105 if kwargs: |
105 if 'callback' in kwargs: | 106 if 'callback' in kwargs: |
106 async = True | 107 async = True |
107 _callback = kwargs.pop('callback') | 108 _callback = kwargs.pop('callback') |
108 _errback = kwargs.pop('errback', lambda failure: log.error(unicode(failure))) | 109 _errback = kwargs.pop('errback', lambda failure: log.error(unicode(failure))) |
110 try: | |
111 args.append(kwargs.pop('profile')) | |
112 except KeyError: | |
113 try: | |
114 args.append(kwargs.pop('profile_key')) | |
115 except KeyError: | |
116 pass | |
117 # at this point, kwargs should be empty | |
118 if kwargs: | |
119 log.warnings(u"unexpected keyword arguments, they will be ignored: {}".format(kwargs)) | |
109 elif len(args) >= 2 and callable(args[-1]) and callable(args[-2]): | 120 elif len(args) >= 2 and callable(args[-1]) and callable(args[-2]): |
110 async = True | 121 async = True |
111 args = list(args) | |
112 _errback = args.pop() | 122 _errback = args.pop() |
113 _callback = args.pop() | 123 _callback = args.pop() |
114 | 124 |
115 method = getattr(self.db_plugin_iface, name) | 125 method = getattr(self.db_plugin_iface, name) |
116 | 126 |