merge from master

This commit is contained in:
2013-08-20 16:33:32 +02:00
5 changed files with 209 additions and 107 deletions

View File

@ -29,7 +29,8 @@ from tiramisu.i18n import _
default_encoding = 'utf-8'
expires_time = 5
ro_remove = ('permissive', 'hidden')
ro_append = ('frozen', 'disabled', 'validator', 'everything_frozen', 'mandatory')
ro_append = ('frozen', 'disabled', 'validator', 'everything_frozen',
'mandatory')
rw_remove = ('permissive', 'everything_frozen', 'mandatory')
rw_append = ('frozen', 'disabled', 'validator', 'hidden')
default_properties = ('expire', 'validator')
@ -287,8 +288,8 @@ class Settings(object):
properties -= frozenset(('mandatory', 'frozen'))
else:
if 'mandatory' in properties and \
not self.context.cfgimpl_get_values()._isempty(opt_or_descr,
value):
not self.context.cfgimpl_get_values()._isempty(
opt_or_descr, value):
properties.remove('mandatory')
if is_write and 'everything_frozen' in self_properties:
properties.add('frozen')
@ -299,12 +300,15 @@ class Settings(object):
props = list(properties)
if 'frozen' in properties:
raise PropertiesOptionError(_('cannot change the value for '
'option {0} this option is frozen'
'').format(opt_or_descr._name), props)
'option {0} this option is'
' frozen').format(
opt_or_descr._name),
props)
else:
raise PropertiesOptionError(_("trying to access to an option "
"named: {0} with properties {1}"
"").format(opt_or_descr._name, str(props)), props)
"").format(opt_or_descr._name,
str(props)), props)
#FIXME should be setpermissive
def set_permissive(self, permissive, opt=None):
@ -355,12 +359,13 @@ class Settings(object):
for requires in opt._requires:
matches = False
for require in requires:
option, expected, action, inverse, transitive, same_action = require
option, expected, action, inverse, \
transitive, same_action = require
path = descr.impl_get_path_by_opt(option)
if path == optpath or path.startswith(optpath + '.'):
raise RequirementError(_("malformed requirements "
"imbrication detected for option: '{0}' "
"with requirement on: '{1}'").format(optpath, path))
"imbrication detected for option: '{0}' "
"with requirement on: '{1}'").format(optpath, path))
try:
value = self.context._getattr(path, force_permissive=True)
except PropertiesOptionError, err:
@ -368,15 +373,21 @@ class Settings(object):
continue
properties = err.proptype
if same_action and action not in properties:
raise RequirementError(_("option '{0}' has requirement's property error: "
"{1} {2}").format(opt._name, path, properties))
raise RequirementError(_("option '{0}' has "
"requirement's property "
"error: "
"{1} {2}").format(opt._name,
path,
properties))
#transitive action, force expected
value = expected[0]
inverse = False
except AttributeError:
raise AttributeError(_("required option not found: "
"{0}").format(path))
if not inverse and value in expected or inverse and value not in expected:
if (not inverse and
value in expected or
inverse and value not in expected):
matches = True
setting.append(action)
## the calculation cannot be carried out