Mercurial > libervia-web
comparison src/browser/collections.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 | |
children | 2664fe93ceb3 |
comparison
equal
deleted
inserted
replaced
585:bade589dbd5a | 589:a5019e62c3e9 |
---|---|
1 #!/usr/bin/python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # Libervia: a Salut à Toi frontend | |
5 # Copyright (C) 2014 Jérôme Poisson <goffi@goffi.org> | |
6 | |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 class OrderedDict(object): | |
21 """Naive implementation of OrderedDict which is compatible with pyjamas""" | |
22 | |
23 def __init__(self, *args, **kwargs): | |
24 self.__internal_dict = {} | |
25 self.__keys = [] # this list keep the keys in order | |
26 if args: | |
27 if len(args)>1: | |
28 raise TypeError("OrderedDict expected at most 1 arguments, got {}".format(len(args))) | |
29 if isinstance(args[0], (dict, OrderedDict)): | |
30 for key, value in args[0].iteritems(): | |
31 self[key] = value | |
32 for key, value in args[0]: | |
33 self[key] = value | |
34 | |
35 def __setitem__(self, key, value): | |
36 self.__keys.append(key) | |
37 self.__internal_dict[key] = value | |
38 | |
39 def __getitem__(self, key): | |
40 return self.__internal_dict[key] | |
41 | |
42 def __delitem__(self, key): | |
43 del self.__internal_dict[key] | |
44 self.__keys.remove(key) | |
45 | |
46 def clear(self): | |
47 self.__internal_dict.clear() | |
48 del self.__keys[:] | |
49 | |
50 def copy(self): | |
51 return OrderedDict(self) | |
52 | |
53 @classmethod | |
54 def fromkeys(cls, seq, value=None): | |
55 ret = OrderedDict() | |
56 for key in seq: | |
57 ret[key] = value | |
58 return ret | |
59 | |
60 def get(self, key, default=None): | |
61 try: | |
62 return self.__internal_dict[key] | |
63 except KeyError: | |
64 return default | |
65 | |
66 def has_key(self, key): | |
67 return key in self.__keys | |
68 | |
69 def keys(self): | |
70 return self.__keys[:] | |
71 | |
72 def iterkeys(self): | |
73 for key in self.__keys: | |
74 yield key | |
75 | |
76 def items(self): | |
77 ret = [] | |
78 for key in self.__keys: | |
79 ret.append((key, self.__internal_dict[key])) | |
80 return ret | |
81 | |
82 def iteritems(self): | |
83 for key in self.__keys: | |
84 yield (key, self.__internal_dict[key]) | |
85 | |
86 def values(self): | |
87 ret = [] | |
88 for key in self.__keys: | |
89 ret.append(self.__internal_dict[key]) | |
90 return ret | |
91 | |
92 def itervalues(self): | |
93 for key in self.__keys: | |
94 yield (self.__internal_dict[key]) | |
95 | |
96 def popitem(self, last=True): | |
97 try: | |
98 key = self.__keys.pop(-1 if last else 0) | |
99 except IndexError: | |
100 raise KeyError('dictionnary is empty') | |
101 value = self.__internal_dict.pop(key) | |
102 return((key, value)) | |
103 | |
104 def setdefault(self, key, default=None): | |
105 try: | |
106 return self.__internal_dict[key] | |
107 except KeyError: | |
108 self.__internal_dict[key] = default | |
109 return default | |
110 | |
111 def update(self, *args, **kwargs): | |
112 if len(args) > 1: | |
113 raise TypeError('udpate expected at most 1 argument, got {}'.format(len(args))) | |
114 if args: | |
115 if hasattr(args[0], 'keys'): | |
116 for k in args[0]: | |
117 self[k] = args[0][k] | |
118 else: | |
119 for (k, v) in args[0]: | |
120 self[k] = v | |
121 for k, v in kwargs.items(): | |
122 self[k] = v | |
123 | |
124 def pop(self, *args): | |
125 if not args: | |
126 raise TypeError('pop expected at least 1 argument, got 0') | |
127 try: | |
128 self.__internal_dict.pop(args[0]) | |
129 except KeyError: | |
130 if len(args) == 2: | |
131 return args[1] | |
132 raise KeyError(args[0]) | |
133 self.__keys.remove(args[0]) | |
134 | |
135 def viewitems(): | |
136 raise NotImplementedError | |
137 | |
138 def viewkeys(): | |
139 raise NotImplementedError | |
140 | |
141 def viewvalues(): | |
142 raise NotImplementedError |