Merge branch 'master' of ssh://git.labs.libre-entreprise.org/gitroot/tiramisu
This commit is contained in:
@ -385,13 +385,17 @@ class Settings(object):
|
||||
#____________________________________________________________
|
||||
def validate_properties(self, opt_or_descr, is_descr, is_write, path,
|
||||
value=None, force_permissive=False,
|
||||
force_properties=None):
|
||||
force_properties=None, force_permissives=None):
|
||||
"""
|
||||
validation upon the properties related to `opt_or_descr`
|
||||
|
||||
:param opt_or_descr: an option or an option description object
|
||||
:param force_permissive: behaves as if the permissive property
|
||||
was present
|
||||
:param force_properties: set() with properties that is force to add
|
||||
in global properties
|
||||
:param force_permissives: set() with permissives that is force to add
|
||||
in global permissives
|
||||
:param is_descr: we have to know if we are in an option description,
|
||||
just because the mandatory property
|
||||
doesn't exist here
|
||||
@ -408,6 +412,8 @@ class Settings(object):
|
||||
self_properties = copy(self._getproperties())
|
||||
if force_permissive is True or 'permissive' in self_properties:
|
||||
properties -= self._p_.getpermissive()
|
||||
if force_permissives is not None:
|
||||
properties -= force_permissives
|
||||
|
||||
# global properties
|
||||
if force_properties is not None:
|
||||
|
@ -177,9 +177,16 @@ class Values(object):
|
||||
# options with callbacks
|
||||
setting = self.context().cfgimpl_get_settings()
|
||||
is_frozen = 'frozen' in setting[opt]
|
||||
# For calculating properties, we need value (ie for mandatory value).
|
||||
# If value is calculating with a PropertiesOptionError's option
|
||||
# _getcallback_value raise a ConfigError.
|
||||
# We can not raise ConfigError if this option should raise
|
||||
# PropertiesOptionError too. So we get config_error and raise
|
||||
# ConfigError if properties did not raise.
|
||||
config_error = None
|
||||
force_permissives = None
|
||||
# if value is callback and is not set
|
||||
# or frozen with force_default_on_freeze
|
||||
config_error = None
|
||||
if opt.impl_has_callback() and (
|
||||
self._is_default_owner(path) or
|
||||
(is_frozen and 'force_default_on_freeze' in setting[opt])):
|
||||
@ -198,15 +205,19 @@ class Values(object):
|
||||
value = self._getcallback_value(opt)
|
||||
except ConfigError as config_error:
|
||||
value = None
|
||||
# should not raise PropertiesOptionError if option is
|
||||
# mandatory
|
||||
force_permissives = set(['mandatory'])
|
||||
else:
|
||||
if (opt.impl_is_multi() and
|
||||
opt.impl_get_multitype() == multitypes.slave):
|
||||
if not isinstance(value, list):
|
||||
value = [value for i in range(lenmaster)]
|
||||
if opt.impl_is_multi():
|
||||
value = Multi(value, self.context, opt, path, validate)
|
||||
# suppress value if already set
|
||||
self.reset(opt, path)
|
||||
if config_error is None:
|
||||
if opt.impl_is_multi():
|
||||
value = Multi(value, self.context, opt, path, validate)
|
||||
# suppress value if already set
|
||||
self.reset(opt, path)
|
||||
# frozen and force default
|
||||
elif is_frozen and 'force_default_on_freeze' in setting[opt]:
|
||||
value = self._getdefault(opt)
|
||||
@ -214,15 +225,16 @@ class Values(object):
|
||||
value = Multi(value, self.context, opt, path, validate)
|
||||
else:
|
||||
value = self._getvalue(opt, path, validate)
|
||||
if validate:
|
||||
if config_error is None and validate:
|
||||
opt.impl_validate(value, self.context(), 'validator' in setting)
|
||||
if self._is_default_owner(path) and \
|
||||
if config_error is None and self._is_default_owner(path) and \
|
||||
'force_store_value' in setting[opt]:
|
||||
self.setitem(opt, value, path, is_write=False)
|
||||
if validate_properties:
|
||||
setting.validate_properties(opt, False, False, value=value, path=path,
|
||||
force_permissive=force_permissive,
|
||||
force_properties=force_properties)
|
||||
force_properties=force_properties,
|
||||
force_permissives=force_permissives)
|
||||
if config_error is not None:
|
||||
raise ConfigError(config_error)
|
||||
return value
|
||||
|
Reference in New Issue
Block a user