From 2e21f1338761e311c07a039ab43ebbae33aa9a57 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 23 Apr 2013 16:43:31 +0200 Subject: [PATCH] force_store_value store value but not in write mode --- tiramisu/value.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tiramisu/value.py b/tiramisu/value.py index bc0ceea..9190020 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -122,7 +122,7 @@ class Values(object): ' for option {0}: {1}').format(opt._name, value)) if self.is_default_owner(opt) and \ 'force_store_value' in setting[opt]: - self.setitem(opt, value) + self.setitem(opt, value, is_write=False) setting.validate_properties(opt, False, False, value=value, force_permissive=force_permissive, force_properties=force_properties) @@ -131,10 +131,9 @@ class Values(object): def __setitem__(self, opt, value): self.setitem(opt, value) - def setitem(self, opt, value, force_permissive=False): - self._setitem(opt, value, force_permissive) - - def _setitem(self, opt, value, force_permissive=False, force_properties=None): + def setitem(self, opt, value, force_permissive=False, is_write=True): + #is_write is, for example, used with "force_store_value" + #user didn't change value, so not write #valid opt if not opt.optimpl_validate(value, self.context, 'validator' in self.context.cfgimpl_get_settings()): @@ -143,12 +142,12 @@ class Values(object): if opt.optimpl_is_multi() and not isinstance(value, Multi): value = Multi(value, self.context, opt) self._setvalue(opt, value, force_permissive=force_permissive, - force_properties=force_properties) + is_write=is_write) - def _setvalue(self, opt, value, force_permissive=False, force_properties=None): + def _setvalue(self, opt, value, force_permissive=False, force_properties=None, is_write=True): self.context.cfgimpl_reset_cache() setting = self.context.cfgimpl_get_settings() - setting.validate_properties(opt, False, True, + setting.validate_properties(opt, False, is_write, value=value, force_permissive=force_permissive, force_properties=force_properties)