force_store_value store value but not in write mode

This commit is contained in:
Emmanuel Garette 2013-04-23 16:43:31 +02:00
parent b7580125a5
commit 2e21f13387
1 changed files with 7 additions and 8 deletions

View File

@ -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)