values_params in ChoiceOption must be rebuild

This commit is contained in:
Emmanuel Garette 2018-04-15 22:59:29 +02:00
parent 54b57968bc
commit 1548099388
2 changed files with 6 additions and 4 deletions

View File

@ -173,7 +173,6 @@ class Base(object):
""" """
:add_value: add value as first argument for validator :add_value: add value as first argument for validator
""" """
is_multi = self.impl_is_dynoptiondescription() or self.impl_is_multi() is_multi = self.impl_is_dynoptiondescription() or self.impl_is_multi()
func_args, func_kwargs, func_positional, func_keyword = self._get_function_args(calculator) func_args, func_kwargs, func_positional, func_keyword = self._get_function_args(calculator)
calculator_args, calculator_kwargs = self._get_parameters_args(calculator_params, add_value) calculator_args, calculator_kwargs = self._get_parameters_args(calculator_params, add_value)
@ -279,11 +278,12 @@ class Base(object):
self) self)
callback_params = self._build_calculator_params(callback, callback_params = self._build_calculator_params(callback,
callback_params) callback_params)
# first part is validator
val = getattr(self, '_val_call', (None,))[0] val = getattr(self, '_val_call', (None,))[0]
if callback_params == {}: if callback_params == {}:
val_call = (callback,) val_call = (callback,)
else: else:
val_call = tuple([callback, callback_params]) val_call = (callback, callback_params)
self._val_call = (val, val_call) self._val_call = (val, val_call)
def impl_is_optiondescription(self): def impl_is_optiondescription(self):

View File

@ -60,6 +60,10 @@ class ChoiceOption(Option):
values_params, values_params,
'values', 'values',
self) self)
values_params = self._build_calculator_params(values,
values_params)
if values_params != {}:
self._choice_values_params = values_params
else: else:
if values_params is not None: if values_params is not None:
raise ValueError(_('values is not a function, so values_params must be None')) raise ValueError(_('values is not a function, so values_params must be None'))
@ -67,8 +71,6 @@ class ChoiceOption(Option):
raise TypeError(_('values must be a tuple or a function for {0}' raise TypeError(_('values must be a tuple or a function for {0}'
).format(name)) ).format(name))
self._choice_values = values self._choice_values = values
if values_params is not None:
self._choice_values_params = values_params
super(ChoiceOption, self).__init__(name, super(ChoiceOption, self).__init__(name,
doc, doc,
default=default, default=default,