force_store_value is rebuild if needed

This commit is contained in:
2016-09-22 08:27:18 +02:00
parent 3a5b1090c7
commit 6d71749014
7 changed files with 57 additions and 19 deletions

View File

@ -102,6 +102,9 @@ class OptionDescription(BaseOption, StorageOptionDescription):
"""validate duplicate option and set option has readonly option
"""
if cache_option is None:
if self.impl_is_readonly():
raise ConfigError(_('option description seems to be part of an other '
'config'))
init = True
_consistencies = {}
cache_option = []
@ -189,24 +192,29 @@ class OptionDescription(BaseOption, StorageOptionDescription):
'which is not in Config').format(
opt.impl_getname()))
self._cache_consistencies[opt] = tuple(cons)
self._cache_force_store_values = force_store_values
self._set_readonly(False)
for subpath, option in force_store_values:
value = config.cfgimpl_get_values()._get_cached_value(option,
path=subpath,
validate=False,
trusted_cached_properties=False,
validate_properties=True)
if option.impl_is_master_slaves('slave'):
# problem with index
raise ConfigError(_('a slave ({0}) cannot have '
'force_store_value property').format(subpath))
if option._is_subdyn():
raise ConfigError(_('a dynoption ({0}) cannot have '
'force_store_value property').format(subpath))
config._impl_values._p_.setvalue(subpath, value,
owners.forced, None, session)
del(session)
def impl_build_force_store_values(self, config):
session = config._impl_values._p_.getsession()
for subpath, option in self._cache_force_store_values:
value = config.cfgimpl_get_values()._get_cached_value(option,
path=subpath,
validate=False,
trusted_cached_properties=False,
validate_properties=True)
if option.impl_is_master_slaves('slave'):
# problem with index
raise ConfigError(_('a slave ({0}) cannot have '
'force_store_value property').format(subpath))
if option._is_subdyn():
raise ConfigError(_('a dynoption ({0}) cannot have '
'force_store_value property').format(subpath))
config._impl_values._p_.setvalue(subpath, value,
owners.forced, None, session)
# ____________________________________________________________
def impl_set_group_type(self, group_type):
"""sets a given group object to an OptionDescription