Mercurial > libervia-backend
comparison src/bridge/bridge_constructor/bridge_constructor.py @ 1290:faa1129559b8 frontends_multi_profiles
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
/!\ not finished, everything is still instable !
- bridge: DBus bridge has been modified to allow blocking call to be called in the same way as asynchronous calls
- bridge: calls with a callback and no errback are now possible, default errback log the error
- constants: removed hack to manage presence without OrderedDict, as an OrderedDict like class has been implemented in Libervia
- core: getLastResource has been removed and replaced by getMainResource (there is a global better management of resources)
- various style improvments: use of constants when possible, fixed variable overlaps, import of module instead of direct class import
- frontends: printInfo and printMessage methods in (Quick)Chat are more generic (use of extra instead of timestamp)
- frontends: bridge creation and option parsing (command line arguments) are now specified by the frontend in QuickApp __init__
- frontends: ProfileManager manage a more complete plug sequence (some stuff formerly manage in contact_list have moved to ProfileManager)
- quick_frontend (quick_widgets): QuickWidgetsManager is now iterable (all widgets are then returned), or can return an iterator on a specific class (return all widgets of this class) with getWidgets
- frontends: tools.jid can now be used in Pyjamas, with some care
- frontends (XMLUI): profile is now managed
- core (memory): big improvment on entities cache management (and specially resource management)
- core (params/exceptions): added PermissionError
- various fixes and improvments, check diff for more details
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 24 Jan 2015 01:00:29 +0100 |
parents | c1e916594e09 |
children | 069ad98b360d |
comparison
equal
deleted
inserted
replaced
1289:653f2e2eea31 | 1290:faa1129559b8 |
---|---|
444 'category': 'plugin' if function['category'] == 'plugin' else 'core', | 444 'category': 'plugin' if function['category'] == 'plugin' else 'core', |
445 'name': section, | 445 'name': section, |
446 'args': self.getArguments(function['sig_in'], name=arg_doc, default=default)} | 446 'args': self.getArguments(function['sig_in'], name=arg_doc, default=default)} |
447 | 447 |
448 if function["type"] == "method": | 448 if function["type"] == "method": |
449 # XXX: we can manage blocking call in the same way as async one: if callback is None the call will be blocking | |
449 completion['debug'] = "" if not self.options.debug else 'log.debug ("%s")\n%s' % (section, 8 * ' ') | 450 completion['debug'] = "" if not self.options.debug else 'log.debug ("%s")\n%s' % (section, 8 * ' ') |
450 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc) | 451 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc) |
451 completion['async_args'] = 'callback=None, errback=None' if async else '' | 452 completion['async_args'] = 'callback=None, errback=None' |
452 completion['async_comma'] = ', ' if async and function['sig_in'] else '' | 453 completion['async_comma'] = ', ' if function['sig_in'] else '' |
453 completion['error_handler'] = ("error_handler = None if callback is None else lambda err:errback(dbus_to_bridge_exception(err))\n" + 8*" ") if async else '' | 454 completion['error_handler'] = """if callback is None: |
454 completion['async_args_result'] = 'timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler' if async else '' | 455 error_handler = None |
456 else: | |
457 if errback is None: | |
458 errback = log.error | |
459 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | |
460 """ | |
461 if async: | |
462 completion['blocking_call'] = '' | |
463 completion['async_args_result'] = 'timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler' | |
464 else: | |
465 # XXX: To have a blocking call, we must have not reply_handler, so we test if callback exists, and add reply_handler only in this case | |
466 completion['blocking_call'] = """kwargs={} | |
467 if callback is not None: | |
468 kwargs['timeout'] = const_TIMEOUT | |
469 kwargs['reply_handler'] = callback | |
470 kwargs['error_handler'] = error_handler | |
471 """ | |
472 completion['async_args_result'] = '**kwargs' | |
455 result = "self.db_%(category)s_iface.%(name)s(%(args_result)s%(async_comma)s%(async_args_result)s)" % completion | 473 result = "self.db_%(category)s_iface.%(name)s(%(args_result)s%(async_comma)s%(async_args_result)s)" % completion |
456 completion['result'] = ("unicode(%s)" if self.options.unicode and function['sig_out'] == 's' else "%s") % result | 474 completion['result'] = ("unicode(%s)" if self.options.unicode and function['sig_out'] == 's' else "%s") % result |
457 methods_part.append("""\ | 475 methods_part.append("""\ |
458 def %(name)s(self, %(args)s%(async_comma)s%(async_args)s): | 476 def %(name)s(self, %(args)s%(async_comma)s%(async_args)s): |
459 %(error_handler)s%(debug)sreturn %(result)s | 477 %(error_handler)s%(blocking_call)s%(debug)sreturn %(result)s |
460 """ % completion) | 478 """ % completion) |
461 | 479 |
462 #at this point, methods_part should be filled, | 480 #at this point, methods_part should be filled, |
463 #we just have to place it in the right part of the template | 481 #we just have to place it in the right part of the template |
464 frontend_bridge = [] | 482 frontend_bridge = [] |