# HG changeset patch # User Goffi # Date 1423245951 -3600 # Node ID 1a61b18703c4563ce9380af427270163169253c8 # Parent d3ef3894254de24e02b0d2b8cf8c0d3fbb7e1375 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) diff -r d3ef3894254d -r 1a61b18703c4 frontends/src/quick_frontend/quick_widgets.py --- 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: