slave's requires with multi is different than slave's requires with non multi option
This commit is contained in:
@ -185,51 +185,48 @@ class MasterSlaves(object):
|
||||
master_is_meta = values._is_meta(master, masterp, session)
|
||||
multi = values._get_multi(opt, path)
|
||||
#if masterlen is [], test properties (has no value, don't get any value)
|
||||
if masterlen == 0:
|
||||
if validate_properties:
|
||||
props = context.cfgimpl_get_settings().validate_properties(opt, False,
|
||||
False,
|
||||
value=multi,
|
||||
path=path,
|
||||
force_permissive=force_permissive,
|
||||
setting_properties=setting_properties)
|
||||
if props:
|
||||
return props
|
||||
#if masterlen == 0:
|
||||
if validate_properties:
|
||||
props = context.cfgimpl_get_settings().validate_properties(opt, False,
|
||||
False,
|
||||
value=multi,
|
||||
path=path,
|
||||
force_permissive=force_permissive,
|
||||
setting_properties=setting_properties)
|
||||
if props:
|
||||
return props
|
||||
#else:
|
||||
if index is None:
|
||||
indexes = range(0, masterlen)
|
||||
else:
|
||||
one_has_value = False
|
||||
if index is None:
|
||||
indexes = range(0, masterlen)
|
||||
else:
|
||||
indexes = [index]
|
||||
for idx in indexes:
|
||||
value = values._get_cached_value(opt, path, validate,
|
||||
force_permissive,
|
||||
trusted_cached_properties,
|
||||
validate_properties,
|
||||
with_meta=master_is_meta,
|
||||
index=idx,
|
||||
# not self_properties,
|
||||
# depends to index
|
||||
#self_properties=self_properties,
|
||||
setting_properties=setting_properties,
|
||||
masterlen=masterlen,
|
||||
from_masterslave=True)
|
||||
if isinstance(value, Exception):
|
||||
if isinstance(value, PropertiesOptionError):
|
||||
err = value
|
||||
indexes = [index]
|
||||
for idx in indexes:
|
||||
value = values._get_cached_value(opt, path, validate,
|
||||
force_permissive,
|
||||
trusted_cached_properties,
|
||||
validate_properties,
|
||||
with_meta=master_is_meta,
|
||||
index=idx,
|
||||
# not self_properties,
|
||||
# depends to index
|
||||
#self_properties=self_properties,
|
||||
setting_properties=setting_properties,
|
||||
masterlen=masterlen,
|
||||
from_masterslave=True)
|
||||
if isinstance(value, Exception):
|
||||
if isinstance(value, PropertiesOptionError):
|
||||
err = value
|
||||
if index is None:
|
||||
multi.append_properties_error(value)
|
||||
else:
|
||||
return value
|
||||
elif index is None:
|
||||
multi.append(value, setitem=False, force=True, validate=validate,
|
||||
force_permissive=force_permissive)
|
||||
one_has_value = True
|
||||
multi = value
|
||||
else:
|
||||
multi = value
|
||||
one_has_value = True
|
||||
if not one_has_value:
|
||||
#raise last err
|
||||
return err
|
||||
return value
|
||||
elif index is None:
|
||||
multi.append(value, setitem=False, force=True, validate=validate,
|
||||
force_permissive=force_permissive)
|
||||
else:
|
||||
multi = value
|
||||
return multi
|
||||
|
||||
def validate(self, values, opt, value, path, session):
|
||||
|
@ -514,9 +514,9 @@ class Settings(object):
|
||||
prop_msg = 'property'
|
||||
else:
|
||||
prop_msg = 'properties'
|
||||
return PropertiesOptionError(_("cannot access to {0} {1} "
|
||||
"because has {2} {3}"
|
||||
"").format(opt_type,
|
||||
return PropertiesOptionError(_('cannot access to {0} "{1}" '
|
||||
'because has {2} {3}'
|
||||
'').format(opt_type,
|
||||
opt_or_descr.impl_get_display_name(),
|
||||
prop_msg,
|
||||
display_list(props)), props,
|
||||
|
@ -604,6 +604,17 @@ class Values(object):
|
||||
settings = context.cfgimpl_get_settings()
|
||||
setting_properties = context.cfgimpl_get_settings()._getproperties()
|
||||
setting_properties.update(['mandatory', 'empty'])
|
||||
def _is_properties_option(err, path):
|
||||
if not isinstance(err, Exception):
|
||||
pass
|
||||
elif isinstance(err, PropertiesOptionError):
|
||||
if err.proptype == ['mandatory']:
|
||||
return path
|
||||
elif isinstance(err, ConfigError):
|
||||
#assume that uncalculated value is an empty value
|
||||
return path
|
||||
else:
|
||||
raise err
|
||||
|
||||
def _mandatory_warnings(description, currpath=None):
|
||||
if currpath is None:
|
||||
@ -633,16 +644,16 @@ class Values(object):
|
||||
self_properties=self_properties,
|
||||
validate=True,
|
||||
display_warnings=False)
|
||||
if not isinstance(err, Exception):
|
||||
pass
|
||||
elif isinstance(err, PropertiesOptionError):
|
||||
if err.proptype == ['mandatory']:
|
||||
yield path
|
||||
elif isinstance(err, ConfigError):
|
||||
#assume that uncalculated value is an empty value
|
||||
yield path
|
||||
if opt.impl_is_master_slaves('slave') and isinstance(err, list):
|
||||
for val in err:
|
||||
ret = _is_properties_option(val, path)
|
||||
if ret is not None:
|
||||
yield ret
|
||||
break
|
||||
else:
|
||||
raise err
|
||||
ret = _is_properties_option(err, path)
|
||||
if ret is not None:
|
||||
yield ret
|
||||
|
||||
descr = self._getcontext().cfgimpl_get_description()
|
||||
for path in _mandatory_warnings(descr):
|
||||
|
Reference in New Issue
Block a user