annotate src/browser/sat_browser/json.py @ 589:a5019e62c3e9 frontends_multi_profiles

browser side: big refactoring to base Libervia on QuickFrontend, first draft: /!\ not finished, partially working and highly instable - add collections module with an OrderedDict like class - SatWebFrontend inherit from QuickApp - general sat_frontends tools.jid module is used - bridge/json methods have moved to json module - UniBox is partially removed (should be totally removed before merge to trunk) - Signals are now register with the generic registerSignal method (which is called mainly in QuickFrontend) - the generic getOrCreateWidget method from QuickWidgetsManager is used instead of Libervia's specific methods - all Widget are now based more or less directly on QuickWidget - with the new QuickWidgetsManager.getWidgets method, it's no more necessary to check all widgets which are instance of a particular class - ChatPanel and related moved to chat module - MicroblogPanel and related moved to blog module - global and overcomplicated send method has been disabled: each class should manage its own sending - for consistency with other frontends, former ContactPanel has been renamed to ContactList and vice versa - for the same reason, ChatPanel has been renamed to Chat - for compatibility with QuickFrontend, a fake profile is used in several places, it is set to C.PROF_KEY_NONE (real profile is managed server side for obvious security reasons) - changed default url for web panel to SàT website, and contact address to generic SàT contact address - ContactList is based on QuickContactList, UI changes are done in update method - bride call (now json module) have been greatly improved, in particular call can be done in the same way as for other frontends (bridge.method_name(arg1, arg2, ..., callback=cb, errback=eb). Blocking method must be called like async methods due to javascript architecture - in bridge calls, a callback can now exists without errback - hard reload on BridgeSignals remote error has been disabled, a better option should be implemented - use of constants where that make sens, some style improvments - avatars are temporarily disabled - lot of code disabled, will be fixed or removed before merge - various other changes, check diff for more details server side: manage remote exception on getEntityData, removed getProfileJid call, added getWaitingConf, added getRoomsSubjects
author Goffi <goffi@goffi.org>
date Sat, 24 Jan 2015 01:45:39 +0100
parents src/browser/libervia_main.py@0a06cf833f5a
children 917e271975d9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
3
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
4 # Libervia: a Salut à Toi frontend
340
ce5b33f499c5 dates update
Goffi <goffi@goffi.org>
parents: 339
diff changeset
5 # Copyright (C) 2011, 2012, 2013, 2014 Jérôme Poisson <goffi@goffi.org>
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
6
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
7 # This program is free software: you can redistribute it and/or modify
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
10 # (at your option) any later version.
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
11
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
12 # This program is distributed in the hope that it will be useful,
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
15 # GNU Affero General Public License for more details.
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
16
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 336
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
19
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
20
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
21 ### logging configuration ###
440
88461e9c3e47 browser_side (log): move logging configuration in a "logging" module + use custom backend with console.debug/info/etc output.
Goffi <goffi@goffi.org>
parents: 439
diff changeset
22 from sat.core.log import getLogger
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
23 log = getLogger(__name__)
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
24 ###
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
25
108
fad0e51cf565 on failure, Libervia now wait 5 s before trying again to call the serveur + only room name is now shown in tabs
Goffi <goffi@goffi.org>
parents: 107
diff changeset
26 from pyjamas.Timer import Timer
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
27 from pyjamas import Window
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
28 from pyjamas import JSONService
323
0b7934e75e76 misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents: 321
diff changeset
29
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 462
diff changeset
30 from sat_browser.constants import Const as C
317
bbadd490e63c misc: gather the constants in a single file, as it is done for other frontends
souliane <souliane@mailoo.org>
parents: 316
diff changeset
31
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
32
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
33 class LiberviaMethodProxy(object):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
34 """This class manage calling for one method"""
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
35
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
36 def __init__(self, parent, method):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
37 self._parent = parent
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
38 self._method = method
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
39
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
40 def call(self, *args, **kwargs):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
41 """Method called when self._method attribue is used in JSON_PROXY_PARENT
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
42
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
43 This method manage callback/errback in kwargs, and profile(_key) removing
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
44 @param *args: positional arguments of self._method
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
45 @param **kwargs: keyword arguments of self._method
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
46 """
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
47 callback=kwargs.pop('callback', None)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
48 errback=kwargs.pop('errback', None)
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 229
diff changeset
49
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
50 # as profile is linked to browser session and managed server side, we remove them
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
51 profile_removed = False
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
52 try:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
53 kwargs['profile'] # FIXME: workaround for pyjamas bug: KeyError is not raised iwith del
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
54 del kwargs['profile']
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
55 profile_removed = True
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
56 except KeyError:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
57 pass
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
58
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
59 try:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
60 kwargs['profile_key'] # FIXME: workaround for pyjamas bug: KeyError is not raised iwith del
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
61 del kwargs['profile_key']
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
62 profile_removed = True
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
63 except KeyError:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
64 pass
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 229
diff changeset
65
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
66 if not profile_removed and args:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
67 # if profile was not in kwargs, there is most probably one in args
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
68 args = list(args)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
69 assert isinstance(args[-1], basestring) # Detect when we want to remove a callback (or something else) instead of the profile
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
70 del args[-1]
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
71
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
72 if kwargs:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
73 # kwargs should be empty here, we don't manage keyword arguments on bridge calls
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
74 log.error("kwargs is not empty after treatment on method call: kwargs={}".format(kwargs))
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
75
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
76 id_ = self._parent.callMethod(self._method, args)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
77
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
78 # callback or errback are managed in parent LiberviaJsonProxy with call id
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
79 if callback is not None:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
80 self._parent.cb[id_] = callback
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
81 if errback is not None:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
82 self._parent.eb[id_] = errback
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 229
diff changeset
83
58
4fa3d57f72f8 browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents: 57
diff changeset
84
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
85 class LiberviaJsonProxy(JSONService.JSONService):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
86
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
87 def __init__(self, url, methods):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
88 self._serviceURL = url
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
89 self.methods = methods
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
90 JSONService.JSONService.__init__(self, url, self)
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
91 self.cb = {}
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
92 self.eb = {}
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
93 self._registerMethods(methods)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
94
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
95 def _registerMethods(self, methods):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
96 if methods:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
97 for method in methods:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
98 log.debug("Registering JSON method call [{}]".format(method))
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
99 setattr(self,
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
100 method,
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
101 getattr(LiberviaMethodProxy(self, method), 'call')
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
102 )
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
103
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
104 def callMethod(self, method, params, handler = None):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
105 ret = super(LiberviaJsonProxy, self).callMethod(method, params, handler)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
106 return ret
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
107
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
108 def call(self, method, cb, *args):
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
109 # FIXME: deprecated call method, must be removed once it's not used anymore
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
110 id_ = self.callMethod(method, args)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
111 log.debug("call: method={} [id={}], args={}".format(method, id_, args))
11
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
112 if cb:
203
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
113 if isinstance(cb, tuple):
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
114 if len(cb) != 2:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
115 log.error("tuple syntax for bridge.call is (callback, errback), aborting")
203
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
116 return
296
92d76ab67156 server+browser side: fixed bridge errback handling
Goffi <goffi@goffi.org>
parents: 285
diff changeset
117 if cb[0] is not None:
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
118 self.cb[id_] = cb[0]
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
119 self.eb[id_] = cb[1]
203
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
120 else:
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
121 self.cb[id_] = cb
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
122
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
123 def onRemoteResponse(self, response, request_info):
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
124 try:
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
125 _cb = self.cb[request_info.id]
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
126 except KeyError:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
127 pass
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
128 else:
203
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
129 # if isinstance(_cb, tuple):
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
130 # #we have arguments attached to the callback
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
131 # #we send them after the answer
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
132 # callback, args = _cb
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
133 # callback(response, *args)
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
134 # else:
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
135 # #No additional argument, we call directly the callback
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
136 _cb(response)
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 28
diff changeset
137 del self.cb[request_info.id]
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
138
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
139 try:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
140 del self.eb[request_info.id]
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
141 except KeyError:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
142 pass
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
143
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
144 def onRemoteError(self, code, errobj, request_info):
62
12e889a683ce server side: misc stuff:
Goffi <goffi@goffi.org>
parents: 58
diff changeset
145 """def dump(obj):
12e889a683ce server side: misc stuff:
Goffi <goffi@goffi.org>
parents: 58
diff changeset
146 print "\n\nDUMPING %s\n\n" % obj
12e889a683ce server side: misc stuff:
Goffi <goffi@goffi.org>
parents: 58
diff changeset
147 for i in dir(obj):
12e889a683ce server side: misc stuff:
Goffi <goffi@goffi.org>
parents: 58
diff changeset
148 print "%s: %s" % (i, getattr(obj,i))"""
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
149 try:
203
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
150 _eb = self.eb[request_info.id]
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
151 except KeyError:
203
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
152 if code != 0:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
153 log.error("Internal server error")
203
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
154 """for o in code, error, request_info:
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
155 dump(o)"""
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
156 else:
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
157 if isinstance(errobj['message'], dict):
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
158 log.error("Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString']))
203
5fdea93b2541 browser side: errback management in bridge calls
Goffi <goffi@goffi.org>
parents: 202
diff changeset
159 else:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
160 log.error("%s" % errobj['message'])
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
161 else:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
162 _eb((code, errobj))
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
163 del self.eb[request_info.id]
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
164
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
165 try:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
166 del self.cb[request_info.id]
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
167 except KeyError:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
168 pass
239
b911f2b43fd4 browser_side: added input history in the unibox:
souliane <souliane@mailoo.org>
parents: 235
diff changeset
169
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
170
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
171 class RegisterCall(LiberviaJsonProxy):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
172 def __init__(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
173 LiberviaJsonProxy.__init__(self, "/register_api",
456
da2a7f2b34c9 browser and server sides: use asyncConnect instead of connect
souliane <souliane@mailoo.org>
parents: 455
diff changeset
174 ["isRegistered", "isConnected", "asyncConnect", "registerParams", "getMenus"])
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
175
239
b911f2b43fd4 browser_side: added input history in the unibox:
souliane <souliane@mailoo.org>
parents: 235
diff changeset
176
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
177 class BridgeCall(LiberviaJsonProxy):
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
178 def __init__(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
179 LiberviaJsonProxy.__init__(self, "/json_api",
215
e830a0c60d32 server side: added the security_limit to setParam
souliane <souliane@mailoo.org>
parents: 213
diff changeset
180 ["getContacts", "addContact", "sendMessage", "sendMblog", "sendMblogComment",
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
181 "getLastMblogs", "getMassiveLastMblogs", "getMblogComments",
427
b5b440e6ea16 server + browser side, getPresenceStatuses has been renamed
Goffi <goffi@goffi.org>
parents: 426
diff changeset
182 "getHistory", "getPresenceStatuses", "joinMUC", "mucLeave", "getRoomsJoined",
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
183 "getRoomsSubjects", "inviteMUC", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady",
389
2d782349b88a server_side: display blog comments when you click on a main item header or title
souliane <souliane@mailoo.org>
parents: 381
diff changeset
184 "tarotGamePlayCards", "launchRadioCollective", "getMblogs", "getMblogsWithComments",
215
e830a0c60d32 server side: added the security_limit to setParam
souliane <souliane@mailoo.org>
parents: 213
diff changeset
185 "getWaitingSub", "subscription", "delContact", "updateContact", "getCard",
229
e632f77c4219 bridge: asyncGetParamA takes a security_limit argument
souliane <souliane@mailoo.org>
parents: 227
diff changeset
186 "getEntityData", "getParamsUI", "asyncGetParamA", "setParam", "launchAction",
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 280
diff changeset
187 "disconnect", "chatStateComposing", "getNewAccountDomain", "confirmationAnswer",
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
188 "syntaxConvert", "getAccountDialogUI", "getLastResource", "getWaitingConf",
148
8635bc9db9bf added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents: 146
diff changeset
189 ])
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
190 def __call__(self, *args, **kwargs):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
191 return LiberviaJsonProxy.__call__(self, *args, **kwargs)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
192
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
193 def getConfig(self, dummy1, dummy2): # FIXME
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
194 log.warning("getConfig is not implemeted in Libervia yet")
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
195 return ''
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
196
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
197 def isConnected(self, dummy): # FIXME
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
198 log.warning("isConnected is not implemeted in Libervia as for now profile is connected if session is opened")
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
199 return True
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
200
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
201 def getAvatarFile(self, hash_, callback=None):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
202 log.warning("getAvatarFile only return hash in Libervia")
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
203 if callback is not None:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
204 callback(hash_)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
205 return hash_
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
206
242
a25aa882e09a browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents: 239
diff changeset
207
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
208 class BridgeSignals(LiberviaJsonProxy):
157
b17ec3a6a112 browser side: in case of error, retry delay is doubled at each try
Goffi <goffi@goffi.org>
parents: 148
diff changeset
209 RETRY_BASE_DELAY = 1000
b17ec3a6a112 browser side: in case of error, retry delay is doubled at each try
Goffi <goffi@goffi.org>
parents: 148
diff changeset
210
99
ca4fc2b2471b browser side: signal management
Goffi <goffi@goffi.org>
parents: 85
diff changeset
211 def __init__(self, host):
ca4fc2b2471b browser side: signal management
Goffi <goffi@goffi.org>
parents: 85
diff changeset
212 self.host = host
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
213 self.retry_delay = self.RETRY_BASE_DELAY
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
214 LiberviaJsonProxy.__init__(self, "/json_signal_api",
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
215 ["getSignals"])
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
216 self._signals = {} # key: signal name, value: callback
210
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 205
diff changeset
217
157
b17ec3a6a112 browser side: in case of error, retry delay is doubled at each try
Goffi <goffi@goffi.org>
parents: 148
diff changeset
218 def onRemoteResponse(self, response, request_info):
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
219 if self.retry_delay != self.RETRY_BASE_DELAY:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
220 log.info("Connection with server restablished")
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
221 self.retry_delay = self.RETRY_BASE_DELAY
157
b17ec3a6a112 browser side: in case of error, retry delay is doubled at each try
Goffi <goffi@goffi.org>
parents: 148
diff changeset
222 LiberviaJsonProxy.onRemoteResponse(self, response, request_info)
210
3092f6b1710c browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents: 205
diff changeset
223
99
ca4fc2b2471b browser side: signal management
Goffi <goffi@goffi.org>
parents: 85
diff changeset
224 def onRemoteError(self, code, errobj, request_info):
158
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 157
diff changeset
225 if errobj['message'] == 'Empty Response':
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
226 Window.alert (u"Empty reponse bridgeSignal\ncode={}\nrequest_info: id={} method={} handler={}".format(code, request_info.id, request_info.method, request_info.handler))
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
227 # FIXME: to check/replace by a proper session end on disconnected signal
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
228 # Window.getLocation().reload() # XXX: reset page in case of session ended.
274
886b47896f3c browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 269
diff changeset
229 # FIXME: Should be done more properly without hard reload
158
58442ed28f2b browser side: basic disconnection management: hard reload is done on empty signal response
Goffi <goffi@goffi.org>
parents: 157
diff changeset
230 LiberviaJsonProxy.onRemoteError(self, code, errobj, request_info)
99
ca4fc2b2471b browser side: signal management
Goffi <goffi@goffi.org>
parents: 85
diff changeset
231 #we now try to reconnect
274
886b47896f3c browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 269
diff changeset
232 if isinstance(errobj['message'], dict) and errobj['message']['faultCode'] == 0:
886b47896f3c browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 269
diff changeset
233 Window.alert('You are not allowed to connect to server')
108
fad0e51cf565 on failure, Libervia now wait 5 s before trying again to call the serveur + only room name is now shown in tabs
Goffi <goffi@goffi.org>
parents: 107
diff changeset
234 else:
422
20c508f9b32a browser side: fixed bad use of Timer
Goffi <goffi@goffi.org>
parents: 415
diff changeset
235 def _timerCb(timer):
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
236 log.info("Trying to reconnect to server...")
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
237 self.getSignals(callback=self.signalHandler)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
238 log.warning("Lost connection, trying to reconnect in {} s".format(self.retry_delay/1000))
157
b17ec3a6a112 browser side: in case of error, retry delay is doubled at each try
Goffi <goffi@goffi.org>
parents: 148
diff changeset
239 Timer(notify=_timerCb).schedule(self.retry_delay)
b17ec3a6a112 browser side: in case of error, retry delay is doubled at each try
Goffi <goffi@goffi.org>
parents: 148
diff changeset
240 self.retry_delay *= 2
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
241
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
242 def register(self, name, callback, with_profile=True):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
243 """Register a signal
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
244
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
245 @param: name of the signal to register
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
246 @param callback: method to call
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
247 @param with_profile: True if the original bridge method need a profile
267
a76243c02074 browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents: 266
diff changeset
248 """
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
249 log.debug("Registering signal {}".format(name))
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
250 if name in self._signals:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
251 log.error("Trying to register and already registered signal ({})".format(name))
267
a76243c02074 browser_side: changes regarding widgets and tabs:
souliane <souliane@mailoo.org>
parents: 266
diff changeset
252 else:
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
253 self._signals[name] = (callback, with_profile)
426
77d8f55fc5f0 browser_side: hide the presence/status panel until the connection is made
souliane <souliane@mailoo.org>
parents: 422
diff changeset
254
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
255 def signalHandler(self, signal_data):
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
256 self.getSignals(callback=self.signalHandler)
548
530f3fc3e3d7 browser_side: fixes signal callback with no argument (e.g disconnected)
souliane <souliane@mailoo.org>
parents: 536
diff changeset
257 if len(signal_data) == 1:
530f3fc3e3d7 browser_side: fixes signal callback with no argument (e.g disconnected)
souliane <souliane@mailoo.org>
parents: 536
diff changeset
258 signal_data.append([])
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
259 log.debug("Got signal ==> name: %s, params: %s" % (signal_data[0], signal_data[1]))
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
260 name, args = signal_data
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
261 try:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
262 callback, with_profile = self._signals[name]
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
263 except KeyError:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
264 log.warning("Ignoring {} signal: no handler registered !".format(name))
205
ee744ffed7fc browser side: events data are cached until initialisation is finished (we get all microblogs)
Goffi <goffi@goffi.org>
parents: 204
diff changeset
265 return
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
266 if with_profile:
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
267 args.append(C.PROF_KEY_NONE)
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 584
diff changeset
268 callback(*args)