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.
This commit is contained in:
Goffi 2016-01-13 18:44:32 +01:00
commit e7d024784e
2 changed files with 22 additions and 2 deletions

View file

@ -100,15 +100,25 @@ class DBusBridgeFrontend(BridgeFrontend):
# - 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()

View file

@ -100,15 +100,25 @@ class DBusBridgeFrontend(BridgeFrontend):
# - 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()