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