memory (params): parameter jids_list values are specified with <jid>...</jid>
This commit is contained in:
parent
a29630c3b6
commit
9e0b24a4a5
1 changed files with 30 additions and 10 deletions
|
|
@ -28,7 +28,7 @@ log = getLogger(__name__)
|
|||
from twisted.internet import defer
|
||||
from twisted.python.failure import Failure
|
||||
from twisted.words.protocols.jabber import jid
|
||||
from sat.tools.xml_tools import paramsXML2XMLUI
|
||||
from sat.tools.xml_tools import paramsXML2XMLUI, getText
|
||||
|
||||
# TODO: params should be rewritten using Twisted directly instead of minidom
|
||||
# general params should be linked to sat.conf and kept synchronised
|
||||
|
|
@ -374,15 +374,13 @@ class Params(object):
|
|||
log.error(_(u'Parameter (%(cat)s, %(param)s) of type list has more than one default option!') % {'cat': cat, 'param': param})
|
||||
raise exceptions.DataError
|
||||
elif node.getAttribute('type') == 'jids_list':
|
||||
if not value_to_use:
|
||||
log.debug(u"jids list value is empty")
|
||||
return []
|
||||
jids = value_to_use.split('\t')
|
||||
assert not value_to_use # only accept <jid>...</jid> and not <param value...>
|
||||
jids = [getText(jid_) for jid_ in node.getElementsByTagName("jid")]
|
||||
to_delete = []
|
||||
for idx, value in enumerate(jids):
|
||||
try:
|
||||
jids[idx] = jid.JID(value)
|
||||
except jid.InvalidFormat:
|
||||
except (RuntimeError, jid.InvalidFormat, AttributeError):
|
||||
log.warning(u"Incorrect jid value found in jids list: [{}]".format(value))
|
||||
to_delete.append(value)
|
||||
for value in to_delete:
|
||||
|
|
@ -679,11 +677,16 @@ class Params(object):
|
|||
except NotFoundErr:
|
||||
pass
|
||||
elif dest_params[name].getAttribute('type') == 'jids_list':
|
||||
jids = profile_value.split('\t') # FIXME: it's not good to use tabs as separator !
|
||||
jids = [getText(jid_) for jid_ in dest_params[name].getElementsByTagName("jid")]
|
||||
for jid_ in jids:
|
||||
jid_elt = prof_xml.createElement('jid')
|
||||
jid_elt.appendChild(prof_xml.createTextNode(jid_))
|
||||
dest_params[name].appendChild(jid_elt)
|
||||
try:
|
||||
jid.JID(jid_)
|
||||
except (RuntimeError, jid.InvalidFormat, AttributeError):
|
||||
log.warning(u"Incorrect jid value found in jids list: [{}]".format(jid_))
|
||||
else:
|
||||
jid_elt = prof_xml.createElement('jid')
|
||||
jid_elt.appendChild(prof_xml.createTextNode())
|
||||
dest_params[name].appendChild(jid_elt)
|
||||
else:
|
||||
dest_params[name].setAttribute('value', profile_value)
|
||||
if new_node:
|
||||
|
|
|
|||
Loading…
Reference in a new issue