better follower properties

This commit is contained in:
Emmanuel Garette 2019-11-20 08:24:13 +01:00
parent 8fa91abefb
commit 9d5bae9305
1 changed files with 12 additions and 8 deletions

View File

@ -214,7 +214,7 @@ class SubConfig(object):
_commit=True):
if option_bag.option.impl_is_symlinkoption():
raise ConfigError(_("can't assign to a SymLinkOption"))
raise ConfigError(_("can't set value to a SymLinkOption"))
context = option_bag.config_bag.context
context.cfgimpl_get_settings().validate_properties(option_bag)
if option_bag.option.impl_is_leader() and len(value) < self._impl_length:
@ -279,7 +279,12 @@ class SubConfig(object):
return context.getattr(soption_bag.path,
soption_bag)
if not from_follower or needs_re_verify_follower_properties:
#if not from_follower or needs_re_verify_follower_properties:
if option.impl_is_follower() and not from_follower:
needs_re_verify_follower_properties = self.cfgimpl_get_settings().has_properties_index(option_bag)
if not option.impl_is_follower() or \
(needs_re_verify_follower_properties and option_bag.index is not None) or \
(not needs_re_verify_follower_properties and (not from_follower or option_bag.index is None)):
self.cfgimpl_get_settings().validate_properties(option_bag)
if option.impl_is_follower() and not from_follower:
@ -292,7 +297,6 @@ class SubConfig(object):
length,
option_bag.index))
if option.impl_is_follower() and option_bag.index is None:
needs_re_verify_follower_properties = self.cfgimpl_get_settings().has_properties_index(option_bag)
value = []
for idx in range(length):
soption_bag = OptionBag()
@ -469,8 +473,7 @@ class SubConfig(object):
#withoption can be set to None below !
if withoption is None:
for opt in self.cfgimpl_get_description().get_children(config_bag,
context):
for opt in self.cfgimpl_get_description().get_children(config_bag):
name = opt.impl_getname()
path = self._get_subpath(name)
soption_bag = OptionBag()
@ -514,15 +517,16 @@ class SubConfig(object):
fullpath,
pathsvalues)
except PropertiesOptionError as err:
if err.proptype == ['mandatory']:
if err.proptype in (['mandatory'], ['empty']):
raise err
pass
else:
try:
ret = self.getattr(name,
option_bag)
except PropertiesOptionError as err:
if err.proptype == ['mandatory']:
# import traceback
# traceback.print_exc()
if err.proptype in (['mandatory'], ['empty']):
raise err
return
if flatten: