Merge remote-tracking branch 'origin/2.0'

This commit is contained in:
2016-09-22 08:28:03 +02:00
7 changed files with 57 additions and 19 deletions

View File

@ -548,6 +548,7 @@ class _CommonConfig(SubConfig):
if not descr.impl_already_build_caches():
descr.impl_build_cache_option()
descr.impl_build_cache(self)
descr.impl_build_force_store_values(self)
def read_only(self):
"read only is a global config's setting, see `settings.py`"
@ -697,7 +698,8 @@ class Config(_CommonConfig):
self._impl_meta = None
#undocumented option used only in test script
self._impl_test = False
self._impl_build_all_caches()
if force_settings is None or force_values is None:
self._impl_build_all_caches()
self._impl_name = name
def cfgimpl_reset_cache(self,

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

View File

@ -363,7 +363,7 @@ class StorageBase(object):
class StorageOptionDescription(StorageBase):
__slots__ = ('_children', '_cache_paths', '_cache_consistencies',
'_group_type', '_state_group_type')
'_group_type', '_state_group_type', '_cache_force_store_values')
def __init__(self, name, multi, warnings_only, doc, extra):
super(StorageOptionDescription, self).__init__(name, multi,