memory (params): forbid to pass a value to a parameter of type "list" with <param value...>
This commit is contained in:
parent
26b892c622
commit
a29630c3b6
1 changed files with 13 additions and 13 deletions
|
|
@ -358,21 +358,21 @@ class Params(object):
|
|||
if node.getAttribute('type') == 'int':
|
||||
return int(value_to_use)
|
||||
elif node.getAttribute('type') == 'list':
|
||||
assert not value_to_use # only accept <option selected...> and not <param value...>
|
||||
options = [option for option in node.childNodes if option.nodeName == 'option']
|
||||
values = [option.getAttribute('value') for option in options]
|
||||
if value_to_use not in values: # value_to_use is probably empty
|
||||
selected = [option for option in options if option.getAttribute('selected') == 'true']
|
||||
cat, param = node.parentNode.getAttribute('name'), node.getAttribute('name')
|
||||
if len(selected) == 1:
|
||||
value_to_use = selected[0].getAttribute('value')
|
||||
log.info(_("Unset parameter (%(cat)s, %(param)s) of type list will use the default option '%(value)s'") %
|
||||
{'cat': cat, 'param': param, 'value': value_to_use})
|
||||
return value_to_use
|
||||
if len(selected) == 0:
|
||||
log.error(_(u'Parameter (%(cat)s, %(param)s) of type list has no default option!') % {'cat': cat, 'param': param})
|
||||
else:
|
||||
log.error(_(u'Parameter (%(cat)s, %(param)s) of type list has more than one default option!') % {'cat': cat, 'param': param})
|
||||
raise exceptions.DataError
|
||||
selected = [option for option in options if option.getAttribute('selected') == 'true']
|
||||
cat, param = node.parentNode.getAttribute('name'), node.getAttribute('name')
|
||||
if len(selected) == 1:
|
||||
value_to_use = selected[0].getAttribute('value')
|
||||
log.info(_("Unset parameter (%(cat)s, %(param)s) of type list will use the default option '%(value)s'") %
|
||||
{'cat': cat, 'param': param, 'value': value_to_use})
|
||||
return value_to_use
|
||||
if len(selected) == 0:
|
||||
log.error(_(u'Parameter (%(cat)s, %(param)s) of type list has no default option!') % {'cat': cat, 'param': param})
|
||||
else:
|
||||
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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue