frontends (xmlui): class_map is now an arg of create function:
class_map was so far used as a global value, but in some cases, several XMLUI managers may be used (it's the case in Cagou's remote controllers plugins, template_xmlui is used to manage remotes). This patch set class_map as a create argument, this way it can be set with partial, and several XMLUI managers can be instanced at the same time.
This commit is contained in:
parent
14fd4252eb
commit
5d6321ec9f
1 changed files with 49 additions and 60 deletions
|
|
@ -25,7 +25,7 @@ from sat_frontends.quick_frontend.constants import Const as C
|
|||
from sat.core import exceptions
|
||||
|
||||
|
||||
class_map = {}
|
||||
_class_map = {}
|
||||
CLASS_PANEL = "panel"
|
||||
CLASS_DIALOG = "dialog"
|
||||
CURRENT_LABEL = "current_label"
|
||||
|
|
@ -986,22 +986,22 @@ def registerClass(type_, class_):
|
|||
CLASS_DIALOG: XMLUI dialog
|
||||
@param class_: the class to use to instanciate given type
|
||||
"""
|
||||
# TODO: remove this method, as there are seme use cases where different XMLUI
|
||||
# classes can be used in the same frontend, so a global value is not good
|
||||
assert type_ in (CLASS_PANEL, CLASS_DIALOG)
|
||||
class_map[type_] = class_
|
||||
log.warning(u"registerClass for XMLUI is deprecated, please use partial with "
|
||||
u"xmlui.create and class_map instead")
|
||||
if type_ in _class_map:
|
||||
log.debug(_(u"XMLUI class already registered for {type_}, ignoring").format(
|
||||
type_=type_))
|
||||
return
|
||||
|
||||
_class_map[type_] = class_
|
||||
|
||||
|
||||
def create(
|
||||
host,
|
||||
xml_data,
|
||||
title=None,
|
||||
flags=None,
|
||||
dom_parse=None,
|
||||
dom_free=None,
|
||||
callback=None,
|
||||
ignore=None,
|
||||
whitelist=None,
|
||||
profile=C.PROF_KEY_NONE,
|
||||
):
|
||||
def create(host, xml_data, title=None, flags=None, dom_parse=None, dom_free=None,
|
||||
callback=None, ignore=None, whitelist=None, class_map=None,
|
||||
profile=C.PROF_KEY_NONE):
|
||||
"""
|
||||
@param dom_parse: methode equivalent to minidom.parseString (but which must manage unicode), or None to use default one
|
||||
@param dom_free: method used to free the parsed DOM
|
||||
|
|
@ -1011,6 +1011,8 @@ def create(
|
|||
when not None, only widgets in this list and their label will be kept
|
||||
mutually exclusive with ignore
|
||||
"""
|
||||
if class_map is None:
|
||||
class_map = _class_map
|
||||
if dom_parse is None:
|
||||
from xml.dom import minidom
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue