Merge branch 'master' of ssh://git.labs.libre-entreprise.org/gitroot/tiramisu

This commit is contained in:
gwen 2013-09-16 15:21:18 +02:00
commit 653eb776bf
2 changed files with 23 additions and 5 deletions

View File

@ -498,3 +498,14 @@ def test_callback_hidden():
cfg.read_write()
raises(PropertiesOptionError, 'cfg.od1.opt1')
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')

View File

@ -179,6 +179,7 @@ class Values(object):
is_frozen = 'frozen' in setting[opt]
# if value is callback and is not set
# or frozen with force_default_on_freeze
config_error = None
if opt.impl_has_callback() and (
self._is_default_owner(path) or
(is_frozen and 'force_default_on_freeze' in setting[opt])):
@ -193,7 +194,11 @@ class Values(object):
no_value_slave = True
if not no_value_slave:
try:
value = self._getcallback_value(opt)
except ConfigError as config_error:
value = None
else:
if (opt.impl_is_multi() and
opt.impl_get_multitype() == multitypes.slave):
if not isinstance(value, list):
@ -218,6 +223,8 @@ class Values(object):
setting.validate_properties(opt, False, False, value=value, path=path,
force_permissive=force_permissive,
force_properties=force_properties)
if config_error is not None:
raise ConfigError(config_error)
return value
def __setitem__(self, opt, value):