comparison src/memory/params.py @ 968:75f3b3b430ff

tools, frontends, memory: param definition and XMLUI handle multi-selection for list widgets: - we need to update urwid_satext to revision 79 - no more "value" attribute value in the "list" element, use HTML-style "select" attribute in the "option" elements instead - /!\ param saving do not handle multiple values yet!
author souliane <souliane@mailoo.org>
date Tue, 01 Apr 2014 21:21:13 +0200
parents e1842ebcb2f3
children 301b342c697a
comparison
equal deleted inserted replaced
967:242bd4fc654c 968:75f3b3b430ff
19 19
20 from sat.core.i18n import _ 20 from sat.core.i18n import _
21 21
22 from sat.core import exceptions 22 from sat.core import exceptions
23 from sat.core.constants import Const as C 23 from sat.core.constants import Const as C
24 from xml.dom import minidom 24 from xml.dom import minidom, NotFoundErr
25 from logging import debug, info, warning, error 25 from logging import debug, info, warning, error
26 from twisted.internet import defer 26 from twisted.internet import defer
27 from twisted.python.failure import Failure 27 from twisted.python.failure import Failure
28 from sat.tools.xml_tools import paramsXML2XMLUI 28 from sat.tools.xml_tools import paramsXML2XMLUI
29 29
492 profile_value = self._getParam(category, 492 profile_value = self._getParam(category,
493 name, type_node.nodeName, 493 name, type_node.nodeName,
494 cache=profile_cache, profile=profile) 494 cache=profile_cache, profile=profile)
495 if profile_value is not None: 495 if profile_value is not None:
496 # there is a value for this profile, we must change the default 496 # there is a value for this profile, we must change the default
497 dest_params[name].setAttribute('value', profile_value) 497 if dest_params[name].getAttribute('type') == 'list':
498 for option in dest_params[name].getElementsByTagName("option"):
499 if option.getAttribute('value') == profile_value:
500 option.setAttribute('selected', 'true')
501 else:
502 try:
503 option.removeAttribute('selected')
504 except NotFoundErr:
505 pass
506 else:
507 dest_params[name].setAttribute('value', profile_value)
498 if new_node: 508 if new_node:
499 prof_xml.documentElement.appendChild(dest_cat) 509 prof_xml.documentElement.appendChild(dest_cat)
500 510
501 to_remove = [] 511 to_remove = []
502 for cat_node in prof_xml.documentElement.childNodes: 512 for cat_node in prof_xml.documentElement.childNodes: