Mercurial > libervia-backend
diff src/memory/params.py @ 1739:a12e5e866d25
memory (params): forbid to pass a value to a parameter of type "list" with <param value...>
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 15 Dec 2015 13:33:35 +0100 |
parents | 59a94105b138 |
children | 681fe91abcc0 |
line wrap: on
line diff
--- a/src/memory/params.py Tue Dec 15 14:25:26 2015 +0100 +++ b/src/memory/params.py Tue Dec 15 13:33:35 2015 +0100 @@ -358,21 +358,21 @@ 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")