From 9d5bae930518b70927018410344c6c42def2777f Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Wed, 20 Nov 2019 08:24:13 +0100 Subject: [PATCH] better follower properties --- tiramisu/config.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tiramisu/config.py b/tiramisu/config.py index 58fdc80..56495d6 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -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: