comparison src/bridge/bridge_constructor/bridge_contructor.py @ 423:6c20c76abdcc

backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred - getParams, getParamsForCategory and getParamsUI are now asynchronous primitivus: management of asynchronous getParamsUI
author Goffi <goffi@goffi.org>
date Mon, 07 Nov 2011 00:09:22 +0100
parents 6c167a2e04b8
children 482b9bcf0ca4
comparison
equal deleted inserted replaced
422:5a18c5f08d9b 423:6c20c76abdcc
391 elif function["type"] == "method": 391 elif function["type"] == "method":
392 completion['debug'] = "" if not self.options.debug else 'debug ("%s")\n%s' % (section,8*' ') 392 completion['debug'] = "" if not self.options.debug else 'debug ("%s")\n%s' % (section,8*' ')
393 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc, unicode_protect=self.options.unicode) 393 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc, unicode_protect=self.options.unicode)
394 completion['async_comma'] = ', ' if async and function['sig_in'] else '' 394 completion['async_comma'] = ', ' if async and function['sig_in'] else ''
395 completion['async_args_def'] = 'callback=None, errback=None' if async else '' 395 completion['async_args_def'] = 'callback=None, errback=None' if async else ''
396 completion['async_args_call'] = 'callback, lambda arg:errback(GenericException(arg))' if async else '' 396 completion['async_args_call'] = 'callback=callback, errback=errback' if async else ''
397 completion['async_callbacks'] = "('callback', 'errback')" if async else "None" 397 completion['async_callbacks'] = "('callback', 'errback')" if async else "None"
398 methods_part.append("""\ 398 methods_part.append("""\
399 @dbus.service.method(const_INT_PREFIX+const_%(category)s_SUFFIX, 399 @dbus.service.method(const_INT_PREFIX+const_%(category)s_SUFFIX,
400 in_signature='%(sig_in)s', out_signature='%(sig_out)s', 400 in_signature='%(sig_in)s', out_signature='%(sig_out)s',
401 async_callbacks=%(async_callbacks)s) 401 async_callbacks=%(async_callbacks)s)
402 def %(name)s(self, %(args)s%(async_comma)s%(async_args_def)s): 402 def %(name)s(self, %(args)s%(async_comma)s%(async_args_def)s):
403 %(debug)sreturn self.cb["%(name)s"](%(args_result)s%(async_comma)s%(async_args_call)s) 403 %(debug)sreturn self._callback("%(name)s", %(args_result)s%(async_comma)s%(async_args_call)s)
404 """ % completion) 404 """ % completion)
405 405
406 #at this point, signals_part, methods_part and direct_calls should be filled, 406 #at this point, signals_part, methods_part and direct_calls should be filled,
407 #we just have to place them in the right part of the template 407 #we just have to place them in the right part of the template
408 core_bridge = [] 408 core_bridge = []