Mercurial > libervia-backend
changeset 1304:1a61b18703c4 frontends_multi_profiles
quick frontend (quick widgets): class' __name__ method is used for classes_map hash because the use of class directly was causing bugs with pyjamas (difficult to find, several MicroblogPanel instances were added only once in Libervia's TabPanel, hash method seemed buggy)
| author | Goffi <goffi@goffi.org> |
|---|---|
| date | Fri, 06 Feb 2015 19:05:51 +0100 |
| parents | d3ef3894254d |
| children | 3dc7f61677bb |
| files | frontends/src/quick_frontend/quick_widgets.py |
| diffstat | 1 files changed, 12 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_widgets.py Fri Feb 06 19:03:13 2015 +0100 +++ b/frontends/src/quick_frontend/quick_widgets.py Fri Feb 06 19:05:51 2015 +0100 @@ -40,7 +40,11 @@ @param child_cls: inherited class to use when Quick... class is requested, must inherit from base_cls. Can be None if it's the base_cls itself which register """ - classes_map[base_cls] = child_cls + # FIXME: we use base_cls.__name__ instead of base_cls directly because pyjamas because + # in the second case + classes_map[base_cls.__name__] = child_cls + + class WidgetAlreadyExistsError(Exception): pass @@ -66,7 +70,9 @@ @return: class actually used to create widget """ try: - cls = classes_map[class_] + # FIXME: we use base_cls.__name__ instead of base_cls directly because pyjamas bugs + # in the second case + cls = classes_map[class_.__name__] except KeyError: cls = class_ if cls is None: @@ -81,7 +87,7 @@ """ class_ = self.getRealClass(class_) try: - widgets_map = self._widgets[class_] + widgets_map = self._widgets[class_.__name__] except KeyError: return iter([]) else: @@ -139,8 +145,9 @@ except KeyError: hash_ = cls.getWidgetHash(target, _kwargs['profiles']) - # widget creation or retrieval - widgets_map = self._widgets.setdefault(cls, {}) # we sorts widgets by classes + ## widget creation or retrieval ## + + widgets_map = self._widgets.setdefault(cls.__name__, {}) # we sorts widgets by classes if not cls.SINGLE: widget = None # if the class is not SINGLE, we always create a new widget else:
