properties validation not in setting and now launch when modify multi

This commit is contained in:
2013-04-17 21:33:34 +02:00
parent 656b751995
commit 3170237c8e
8 changed files with 258 additions and 151 deletions

View File

@ -211,6 +211,41 @@ class Setting(object):
self.set_properties(properties, opt)
#____________________________________________________________
def validate_properties(self, opt_or_descr, is_descr, is_write,
value=None, force_permissive=False,
force_properties=None):
properties = set(self.get_properties(opt_or_descr))
#remove this properties, those properties are validate in after
properties = properties - set(['mandatory', 'frozen'])
set_properties = self.get_properties()
if force_properties is not None:
set_properties.extend(force_properties)
set_properties = set(set_properties)
properties = properties & set_properties
if force_permissive is True or self.has_property('permissive', is_apply_req=False):
properties = properties - set(self.get_permissive())
properties = properties - set(self.get_permissive(opt_or_descr))
properties = list(properties)
raise_text = _("trying to access"
" to an option named: {0} with properties"
" {1}")
if not is_descr:
if self.context.cfgimpl_get_values().is_mandatory_err(opt_or_descr,
value,
force_properties=force_properties):
properties.append('mandatory')
if is_write and (self.has_property('everything_frozen') or (
self.has_property('frozen') and
self.has_property('frozen', opt_or_descr,
is_apply_req=False))):
properties.append('frozen')
raise_text = _('cannot change the value to {0} for '
'option {1} this option is frozen')
if properties != []:
raise PropertiesOptionError(raise_text.format(opt_or_descr._name,
str(properties)),
properties)
def get_permissive(self, opt=None):
return self.permissives.get(opt, [])