when we get an option's value, we need it's values to calculate properties (ie for mandatory's option)
if a disabled option has a callback to an other disabled value, it's raise ConfigError now only raise if option has no other propertiesError
This commit is contained in:
parent
327cce6fed
commit
9ddf100118
|
@ -498,3 +498,14 @@ def test_callback_hidden():
|
||||||
cfg.read_write()
|
cfg.read_write()
|
||||||
raises(PropertiesOptionError, 'cfg.od1.opt1')
|
raises(PropertiesOptionError, 'cfg.od1.opt1')
|
||||||
cfg.od2.opt2
|
cfg.od2.opt2
|
||||||
|
|
||||||
|
|
||||||
|
def test_callback_disable_make_dict():
|
||||||
|
opt1 = BoolOption('opt1', '', properties=('disabled',))
|
||||||
|
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': (('od1.opt1', False),)}, properties=('disabled',))
|
||||||
|
od1 = OptionDescription('od1', '', [opt1])
|
||||||
|
od2 = OptionDescription('od2', '', [opt2])
|
||||||
|
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||||
|
cfg = Config(maconfig)
|
||||||
|
cfg.read_write()
|
||||||
|
raises(PropertiesOptionError, 'cfg.od1.opt1')
|
||||||
|
|
|
@ -179,6 +179,7 @@ class Values(object):
|
||||||
is_frozen = 'frozen' in setting[opt]
|
is_frozen = 'frozen' in setting[opt]
|
||||||
# if value is callback and is not set
|
# if value is callback and is not set
|
||||||
# or frozen with force_default_on_freeze
|
# or frozen with force_default_on_freeze
|
||||||
|
config_error = None
|
||||||
if opt.impl_has_callback() and (
|
if opt.impl_has_callback() and (
|
||||||
self._is_default_owner(path) or
|
self._is_default_owner(path) or
|
||||||
(is_frozen and 'force_default_on_freeze' in setting[opt])):
|
(is_frozen and 'force_default_on_freeze' in setting[opt])):
|
||||||
|
@ -193,11 +194,15 @@ class Values(object):
|
||||||
no_value_slave = True
|
no_value_slave = True
|
||||||
|
|
||||||
if not no_value_slave:
|
if not no_value_slave:
|
||||||
value = self._getcallback_value(opt)
|
try:
|
||||||
if (opt.impl_is_multi() and
|
value = self._getcallback_value(opt)
|
||||||
opt.impl_get_multitype() == multitypes.slave):
|
except ConfigError as config_error:
|
||||||
if not isinstance(value, list):
|
value = None
|
||||||
value = [value for i in range(lenmaster)]
|
else:
|
||||||
|
if (opt.impl_is_multi() and
|
||||||
|
opt.impl_get_multitype() == multitypes.slave):
|
||||||
|
if not isinstance(value, list):
|
||||||
|
value = [value for i in range(lenmaster)]
|
||||||
if opt.impl_is_multi():
|
if opt.impl_is_multi():
|
||||||
value = Multi(value, self.context, opt, path, validate)
|
value = Multi(value, self.context, opt, path, validate)
|
||||||
# suppress value if already set
|
# suppress value if already set
|
||||||
|
@ -218,6 +223,8 @@ class Values(object):
|
||||||
setting.validate_properties(opt, False, False, value=value, path=path,
|
setting.validate_properties(opt, False, False, value=value, path=path,
|
||||||
force_permissive=force_permissive,
|
force_permissive=force_permissive,
|
||||||
force_properties=force_properties)
|
force_properties=force_properties)
|
||||||
|
if config_error is not None:
|
||||||
|
raise ConfigError(config_error)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def __setitem__(self, opt, value):
|
def __setitem__(self, opt, value):
|
||||||
|
|
Loading…
Reference in New Issue