From 866364059c33cebd3b0840cdfe82364a6f6541f6 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 17 Sep 2013 09:10:08 +0200 Subject: [PATCH] dont change anything if config_error --- test/test_option_calculation.py | 11 +++++++++++ tiramisu/value.py | 13 +++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/test/test_option_calculation.py b/test/test_option_calculation.py index 1441460..17f685c 100644 --- a/test/test_option_calculation.py +++ b/test/test_option_calculation.py @@ -531,3 +531,14 @@ def test_callback_calculating_mandatory(): cfg = Config(maconfig) cfg.read_only() raises(ConfigError, 'cfg.od2.opt2') + + +def test_callback_two_disabled_multi(): + opt1 = BoolOption('opt1', '', properties=('disabled',)) + opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': (('od1.opt1', False),)}, properties=('disabled',), multi=True) + od1 = OptionDescription('od1', '', [opt1]) + od2 = OptionDescription('od2', '', [opt2]) + maconfig = OptionDescription('rootconfig', '', [od1, od2]) + cfg = Config(maconfig) + cfg.read_write() + raises(PropertiesOptionError, 'cfg.od2.opt2') diff --git a/tiramisu/value.py b/tiramisu/value.py index 911f4a8..578c4ee 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -213,10 +213,11 @@ class Values(object): opt.impl_get_multitype() == multitypes.slave): if not isinstance(value, list): value = [value for i in range(lenmaster)] - if opt.impl_is_multi(): - value = Multi(value, self.context, opt, path, validate) - # suppress value if already set - self.reset(opt, path) + if config_error is None: + if opt.impl_is_multi(): + value = Multi(value, self.context, opt, path, validate) + # suppress value if already set + self.reset(opt, path) # frozen and force default elif is_frozen and 'force_default_on_freeze' in setting[opt]: value = self._getdefault(opt) @@ -224,9 +225,9 @@ class Values(object): value = Multi(value, self.context, opt, path, validate) else: value = self._getvalue(opt, path, validate) - if validate: + if config_error is None and validate: opt.impl_validate(value, self.context(), 'validator' in setting) - if self._is_default_owner(path) and \ + if config_error is None and self._is_default_owner(path) and \ 'force_store_value' in setting[opt]: self.setitem(opt, value, path, is_write=False) if validate_properties: