remove _getcontext in Settings
This commit is contained in:
parent
09c9fa4906
commit
05404e89bc
|
@ -71,7 +71,7 @@ def autocheck(func):
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_option_multi(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_option_multi(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||||
cfg.option(pathread).option.ismulti()
|
cfg.option(pathread).option.ismulti()
|
||||||
cfg.option(pathread).option.issubmulti()
|
cfg.option(pathread).option.issubmulti()
|
||||||
|
@ -101,7 +101,7 @@ def autocheck_option_multi(cfg, pathread, pathwrite, confread, confwrite, **kwar
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_default_owner(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_default_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
"""check different value of owner when any value is set to this option
|
"""check different value of owner when any value is set to this option
|
||||||
"""
|
"""
|
||||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||||
|
@ -195,7 +195,7 @@ def _autocheck_default_value(cfg, path, conf, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_default_value(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_default_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
_autocheck_default_value(cfg, pathread, confread, **kwargs)
|
_autocheck_default_value(cfg, pathread, confread, **kwargs)
|
||||||
if confread != confwrite:
|
if confread != confwrite:
|
||||||
_autocheck_default_value(cfg, pathread, confwrite, **kwargs)
|
_autocheck_default_value(cfg, pathread, confwrite, **kwargs)
|
||||||
|
@ -276,12 +276,12 @@ def _set_value(cfg, pathwrite, conf, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_set_value(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_set_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_get_value_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_get_value_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||||
|
@ -390,7 +390,7 @@ def _autocheck_get_value(cfg, pathread, conf, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_get_value(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_get_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
_set_value(cfg, pathwrite, confwrite, set_permissive=False, **kwargs)
|
_set_value(cfg, pathwrite, confwrite, set_permissive=False, **kwargs)
|
||||||
_autocheck_get_value(cfg, pathread, confread, set_permissive=False, **kwargs)
|
_autocheck_get_value(cfg, pathread, confread, set_permissive=False, **kwargs)
|
||||||
if pathread.endswith('val1'):
|
if pathread.endswith('val1'):
|
||||||
|
@ -403,7 +403,7 @@ def autocheck_get_value(cfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_value_slave(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_value_slave(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||||
if not isslave:
|
if not isslave:
|
||||||
if kwargs.get('propertyerror', False):
|
if kwargs.get('propertyerror', False):
|
||||||
|
@ -454,7 +454,7 @@ def autocheck_value_slave(cfg, pathread, pathwrite, confread, confwrite, **kwarg
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_reset_value(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_reset_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
# check if is a multi, a master or a slave
|
# check if is a multi, a master or a slave
|
||||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||||
|
@ -509,7 +509,7 @@ def autocheck_reset_value(cfg, pathread, pathwrite, confread, confwrite, **kwarg
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_append_value(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_append_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
ismaster = cfg.unrestraint.option(pathread).option.ismaster()
|
ismaster = cfg.unrestraint.option(pathread).option.ismaster()
|
||||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||||
if not ismaster:
|
if not ismaster:
|
||||||
|
@ -546,7 +546,7 @@ def autocheck_append_value(cfg, pathread, pathwrite, confread, confwrite, **kwar
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_pop_value(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_pop_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
ismaster = cfg.unrestraint.option(pathread).option.ismaster()
|
ismaster = cfg.unrestraint.option(pathread).option.ismaster()
|
||||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||||
if not ismaster:
|
if not ismaster:
|
||||||
|
@ -597,7 +597,7 @@ def autocheck_pop_value(cfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_reset_value_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_reset_value_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
# check if is a multi, a master or a slave
|
# check if is a multi, a master or a slave
|
||||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||||
|
@ -624,7 +624,7 @@ def autocheck_reset_value_permissive(cfg, pathread, pathwrite, confread, confwri
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_display(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_display(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
"""re set value
|
"""re set value
|
||||||
"""
|
"""
|
||||||
if kwargs['callback']:
|
if kwargs['callback']:
|
||||||
|
@ -655,7 +655,7 @@ def _getproperties(multi, isslave, kwargs):
|
||||||
return default_props, frozenset(properties)
|
return default_props, frozenset(properties)
|
||||||
|
|
||||||
|
|
||||||
def _check_properties(cfg, pathread, conf, kwargs, props_permissive, props):
|
def _check_properties(cfg, mcfg, pathread, conf, kwargs, props_permissive, props):
|
||||||
if not cfg.unrestraint.option(pathread).option.isslave():
|
if not cfg.unrestraint.option(pathread).option.isslave():
|
||||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||||
assert set(cfg.config(conf).option(pathread).property.get()) == set(props_permissive)
|
assert set(cfg.config(conf).option(pathread).property.get()) == set(props_permissive)
|
||||||
|
@ -704,7 +704,7 @@ def _check_properties(cfg, pathread, conf, kwargs, props_permissive, props):
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_property(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_property(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
"""get property from path
|
"""get property from path
|
||||||
"""
|
"""
|
||||||
# check if is a multi or a slave
|
# check if is a multi or a slave
|
||||||
|
@ -713,20 +713,20 @@ def autocheck_property(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
|
|
||||||
default_props, properties = _getproperties(multi, isslave, kwargs)
|
default_props, properties = _getproperties(multi, isslave, kwargs)
|
||||||
|
|
||||||
_check_properties(cfg, pathread, confread, kwargs, default_props, default_props)
|
_check_properties(cfg, mcfg, pathread, confread, kwargs, default_props, default_props)
|
||||||
if confread != confwrite:
|
if confread != confwrite:
|
||||||
_check_properties(cfg, pathread, confwrite, kwargs, default_props, default_props)
|
_check_properties(cfg, mcfg, pathread, confwrite, kwargs, default_props, default_props)
|
||||||
|
|
||||||
# set properties without permissive
|
# set properties without permissive
|
||||||
for prop in properties:
|
for prop in properties:
|
||||||
cfg.unrestraint.config(confwrite).option(pathwrite).property.add(prop)
|
cfg.unrestraint.config(confread).option(pathwrite).property.add(prop)
|
||||||
_check_properties(cfg, pathread, confread, kwargs, properties, properties)
|
_check_properties(cfg, mcfg, pathread, confread, kwargs, properties, properties)
|
||||||
if confread != confwrite:
|
#if confread != confwrite:
|
||||||
_check_properties(cfg, pathread, confwrite, kwargs, properties, properties)
|
# _check_properties(cfg, mcfg, pathread, confwrite, kwargs, properties, properties)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _property_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def _property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
# check if is a multi or a slave
|
# check if is a multi or a slave
|
||||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||||
|
@ -744,30 +744,30 @@ def _property_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs
|
||||||
default_props.extend(extra_properties)
|
default_props.extend(extra_properties)
|
||||||
default_props, properties = _getproperties(multi, isslave, kwargs)
|
default_props, properties = _getproperties(multi, isslave, kwargs)
|
||||||
|
|
||||||
_check_properties(cfg, pathread, confwrite, kwargs, default_props, default_props)
|
_check_properties(cfg, mcfg, pathread, confwrite, kwargs, default_props, default_props)
|
||||||
if confwrite != confread:
|
#if confwrite != confread:
|
||||||
_check_properties(cfg, pathread, confread, kwargs, default_props, default_props)
|
# _check_properties(cfg, mcfg, pathread, confread, kwargs, default_props, default_props)
|
||||||
|
|
||||||
# set properties with permissive
|
# set properties with permissive
|
||||||
for prop in properties:
|
for prop in properties:
|
||||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||||
cfg.config(confwrite).option(pathwrite).property.add(prop)
|
cfg.config(confread).option(pathwrite).property.add(prop)
|
||||||
if not kwargs.get('propertyerror', False):
|
if not kwargs.get('propertyerror', False):
|
||||||
cfg.forcepermissive.config(confwrite).option(pathwrite).property.add(prop)
|
cfg.forcepermissive.config(confread).option(pathwrite).property.add(prop)
|
||||||
cfg.unrestraint.config(confwrite).option(pathwrite).property.add(prop)
|
cfg.unrestraint.config(confread).option(pathwrite).property.add(prop)
|
||||||
|
|
||||||
_check_properties(cfg, pathread, confwrite, kwargs, properties, properties)
|
_check_properties(cfg, mcfg, pathread, confwrite, kwargs, properties, properties)
|
||||||
if confwrite != confread:
|
#if confwrite != confread:
|
||||||
_check_properties(cfg, pathread, confread, kwargs, properties, properties)
|
# _check_properties(cfg, mcfg, pathread, confread, kwargs, properties, properties)
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_property_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
_property_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
_property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_reset_property(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_reset_property(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
"""check properties after set with permissive
|
"""check properties after set with permissive
|
||||||
"""
|
"""
|
||||||
# check if is a multi or a slave
|
# check if is a multi or a slave
|
||||||
|
@ -775,36 +775,36 @@ def autocheck_reset_property(cfg, pathread, pathwrite, confread, confwrite, **kw
|
||||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||||
default_props, properties = _getproperties(multi, isslave, kwargs)
|
default_props, properties = _getproperties(multi, isslave, kwargs)
|
||||||
|
|
||||||
_property_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
_property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||||
|
|
||||||
# reset properties without permissive
|
# reset properties without permissive
|
||||||
cfg.unrestraint.config(confwrite).option(pathwrite).property.reset()
|
cfg.unrestraint.config(confwrite).option(pathwrite).property.reset()
|
||||||
|
|
||||||
_check_properties(cfg, pathread, confread, kwargs, default_props, default_props)
|
_check_properties(cfg, mcfg, pathread, confread, kwargs, default_props, default_props)
|
||||||
if confread != confwrite:
|
if confread != confwrite:
|
||||||
_check_properties(cfg, pathread, confwrite, kwargs, default_props, default_props)
|
_check_properties(cfg, mcfg, pathread, confwrite, kwargs, default_props, default_props)
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_reset_property_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_reset_property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
# check if is a multi or a slave
|
# check if is a multi or a slave
|
||||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||||
default_props, properties = _getproperties(multi, isslave, kwargs)
|
default_props, properties = _getproperties(multi, isslave, kwargs)
|
||||||
|
|
||||||
_property_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
_property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||||
|
|
||||||
for prop in properties:
|
for prop in properties:
|
||||||
cfg.unrestraint.option(pathwrite).property.add(prop)
|
cfg.unrestraint.option(pathwrite).property.add(prop)
|
||||||
cfg.unrestraint.option(pathwrite).property.reset()
|
cfg.unrestraint.option(pathwrite).property.reset()
|
||||||
|
|
||||||
_check_properties(cfg, pathread, confwrite, kwargs, default_props, default_props)
|
_check_properties(cfg, mcfg, pathread, confwrite, kwargs, default_props, default_props)
|
||||||
if confread != confwrite:
|
if confread != confwrite:
|
||||||
_check_properties(cfg, pathread, confread, kwargs, default_props, default_props)
|
_check_properties(cfg, mcfg, pathread, confread, kwargs, default_props, default_props)
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_context_owner(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_context_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
owner = cfg.owner.get()
|
owner = cfg.owner.get()
|
||||||
assert owner == kwargs['owner']
|
assert owner == kwargs['owner']
|
||||||
|
|
||||||
|
@ -838,7 +838,7 @@ def _check_owner(cfg, pathread, conf, kwargs, owner, permissive_owner):
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_owner_with_value(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_owner_with_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
"""value is now changed, check owner in this case
|
"""value is now changed, check owner in this case
|
||||||
"""
|
"""
|
||||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||||
|
@ -848,7 +848,7 @@ def autocheck_owner_with_value(cfg, pathread, pathwrite, confread, confwrite, **
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_default_owner_with_value(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_default_owner_with_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||||
|
|
||||||
|
@ -874,7 +874,7 @@ def autocheck_default_owner_with_value(cfg, pathread, pathwrite, confread, confw
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_default_owner_with_value_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_default_owner_with_value_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
# check if is a isslave
|
# check if is a isslave
|
||||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||||
|
|
||||||
|
@ -896,7 +896,7 @@ def autocheck_default_owner_with_value_permissive(cfg, pathread, pathwrite, conf
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_set_owner_no_value(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_set_owner_no_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||||
if not kwargs.get('propertyerror', False):
|
if not kwargs.get('propertyerror', False):
|
||||||
if not isslave:
|
if not isslave:
|
||||||
|
@ -906,7 +906,7 @@ def autocheck_set_owner_no_value(cfg, pathread, pathwrite, confread, confwrite,
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_set_owner(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_set_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
# test set owner without permissive
|
# test set owner without permissive
|
||||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||||
|
|
||||||
|
@ -933,7 +933,7 @@ def autocheck_set_owner(cfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_set_owner_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_set_owner_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||||
|
|
||||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||||
|
@ -958,7 +958,7 @@ def autocheck_set_owner_permissive(cfg, pathread, pathwrite, confread, confwrite
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_option(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_option(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
expected_name = pathread.split('.')[-1]
|
expected_name = pathread.split('.')[-1]
|
||||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||||
current_name = cfg.option(pathread).option.name()
|
current_name = cfg.option(pathread).option.name()
|
||||||
|
@ -991,13 +991,13 @@ def autocheck_option(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
"""test permissive for hidden and disabled value
|
"""test permissive for hidden and disabled value
|
||||||
"""
|
"""
|
||||||
# no permissive before
|
# no permissive before
|
||||||
assert cfg.unrestraint.config(confread).option(pathread).permissive.get() == frozenset()
|
assert cfg.unrestraint.config(confwrite).option(pathread).permissive.get() == frozenset()
|
||||||
if kwargs.get('permissive_od', False):
|
if kwargs.get('permissive_od', False):
|
||||||
assert cfg.unrestraint.config(confread).option(pathread.rsplit('.', 1)[0]).permissive.get() == frozenset()
|
assert cfg.unrestraint.config(confwrite).option(pathread.rsplit('.', 1)[0]).permissive.get() == frozenset()
|
||||||
|
|
||||||
# cannot access to hidden value without forcepermissive
|
# cannot access to hidden value without forcepermissive
|
||||||
# and to disabled value (with forcepermissive too)
|
# and to disabled value (with forcepermissive too)
|
||||||
|
@ -1017,8 +1017,8 @@ def autocheck_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs
|
||||||
|
|
||||||
# have permissive
|
# have permissive
|
||||||
assert cfg.unrestraint.config(confwrite).option(pathread).permissive.get() == frozenset(['disabled'])
|
assert cfg.unrestraint.config(confwrite).option(pathread).permissive.get() == frozenset(['disabled'])
|
||||||
if confwrite != confread:
|
#if confwrite != confread:
|
||||||
assert cfg.unrestraint.config(confread).option(pathread).permissive.get() == frozenset(['disabled'])
|
# assert cfg.unrestraint.config(confread).option(pathread).permissive.get() == frozenset(['disabled'])
|
||||||
|
|
||||||
# can access to disabled value
|
# can access to disabled value
|
||||||
ckwargs = copy(kwargs)
|
ckwargs = copy(kwargs)
|
||||||
|
@ -1042,8 +1042,8 @@ def autocheck_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs
|
||||||
'hidden']))
|
'hidden']))
|
||||||
ckwargs['permissive'] = False
|
ckwargs['permissive'] = False
|
||||||
_autocheck_default_value(cfg, pathread, confread, **ckwargs)
|
_autocheck_default_value(cfg, pathread, confread, **ckwargs)
|
||||||
if confread != confwrite:
|
#if confread != confwrite:
|
||||||
_autocheck_default_value(cfg, pathread, confwrite, **ckwargs)
|
# _autocheck_default_value(cfg, pathread, confwrite, **ckwargs)
|
||||||
|
|
||||||
# only hidden
|
# only hidden
|
||||||
cfg.unrestraint.config(confwrite).option(pathwrite).permissive.set(frozenset(['hidden']))
|
cfg.unrestraint.config(confwrite).option(pathwrite).permissive.set(frozenset(['hidden']))
|
||||||
|
@ -1057,8 +1057,8 @@ def autocheck_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs
|
||||||
ckwargs = copy(kwargs)
|
ckwargs = copy(kwargs)
|
||||||
ckwargs['permissive'] = False
|
ckwargs['permissive'] = False
|
||||||
_autocheck_default_value(cfg, pathread, confread, **ckwargs)
|
_autocheck_default_value(cfg, pathread, confread, **ckwargs)
|
||||||
if confread != confwrite:
|
#if confread != confwrite:
|
||||||
_autocheck_default_value(cfg, pathread, confwrite, **ckwargs)
|
# _autocheck_default_value(cfg, pathread, confwrite, **ckwargs)
|
||||||
|
|
||||||
# no permissive
|
# no permissive
|
||||||
cfg.unrestraint.config(confwrite).option(pathwrite).permissive.set(frozenset())
|
cfg.unrestraint.config(confwrite).option(pathwrite).permissive.set(frozenset())
|
||||||
|
@ -1070,12 +1070,12 @@ def autocheck_permissive(cfg, pathread, pathwrite, confread, confwrite, **kwargs
|
||||||
_autocheck_default_value(cfg, pathread, confwrite, **ckwargs)
|
_autocheck_default_value(cfg, pathread, confwrite, **ckwargs)
|
||||||
cfg.unrestraint.config(confwrite).option(pathwrite.rsplit('.', 1)[0]).permissive.set(frozenset())
|
cfg.unrestraint.config(confwrite).option(pathwrite.rsplit('.', 1)[0]).permissive.set(frozenset())
|
||||||
_autocheck_default_value(cfg, pathread, confread, **kwargs)
|
_autocheck_default_value(cfg, pathread, confread, **kwargs)
|
||||||
if confread != confwrite:
|
#if confread != confwrite:
|
||||||
_autocheck_default_value(cfg, pathread, confwrite, **kwargs)
|
# _autocheck_default_value(cfg, pathread, confwrite, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_option_get(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_option_get(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
if '.' in pathread:
|
if '.' in pathread:
|
||||||
name = pathread.rsplit('.', 1)[1]
|
name = pathread.rsplit('.', 1)[1]
|
||||||
else:
|
else:
|
||||||
|
@ -1084,7 +1084,7 @@ def autocheck_option_get(cfg, pathread, pathwrite, confread, confwrite, **kwargs
|
||||||
|
|
||||||
|
|
||||||
@autocheck
|
@autocheck
|
||||||
def autocheck_find(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
def autocheck_find(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||||
def _getoption(opt):
|
def _getoption(opt):
|
||||||
opt = opt.option.get()
|
opt = opt.option.get()
|
||||||
if opt.impl_is_dynsymlinkoption():
|
if opt.impl_is_dynsymlinkoption():
|
||||||
|
@ -1317,20 +1317,22 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
||||||
for func in autocheck_registers:
|
for func in autocheck_registers:
|
||||||
cfg_name = 'conftest' + str(idx)
|
cfg_name = 'conftest' + str(idx)
|
||||||
idx += 1
|
idx += 1
|
||||||
ncfg = cfg.config.duplicate(session_id=cfg_name)
|
ncfg = cfg.config.copy(session_id=cfg_name)
|
||||||
if meta:
|
if meta:
|
||||||
confwrite = None
|
confwrite = None
|
||||||
confread = cfg_name
|
confread = cfg_name
|
||||||
ncfg = MetaConfig([ncfg], session_id='metatest')
|
mcfg = MetaConfig([ncfg], session_id='metatest')
|
||||||
weakrefs.append(weakref.ref(cfg))
|
weakrefs.append(weakref.ref(cfg))
|
||||||
|
else:
|
||||||
|
mcfg = ncfg
|
||||||
ckwargs = copy(kwargs)
|
ckwargs = copy(kwargs)
|
||||||
if meta:
|
if meta:
|
||||||
ncfg.owner.set('meta')
|
mcfg.owner.set('meta')
|
||||||
ckwargs['owner'] = owners.meta
|
ckwargs['owner'] = owners.meta
|
||||||
else:
|
else:
|
||||||
ckwargs['owner'] = OWNER
|
ckwargs['owner'] = OWNER
|
||||||
|
|
||||||
if ncfg.unrestraint.option(path).option.isslave():
|
if mcfg.unrestraint.option(path).option.isslave():
|
||||||
dirname = path.rsplit('.', 1)[0]
|
dirname = path.rsplit('.', 1)[0]
|
||||||
master_path = dirname + '.first'
|
master_path = dirname + '.first'
|
||||||
master_path_2 = None
|
master_path_2 = None
|
||||||
|
@ -1343,7 +1345,7 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
||||||
else:
|
else:
|
||||||
value = LIST_SECOND_VALUE
|
value = LIST_SECOND_VALUE
|
||||||
with warnings.catch_warnings(record=True) as w:
|
with warnings.catch_warnings(record=True) as w:
|
||||||
ncfg.option(master_path).value.set(value)
|
mcfg.option(master_path).value.set(value)
|
||||||
ckwargs['make_dict'][master_path] = value
|
ckwargs['make_dict'][master_path] = value
|
||||||
ckwargs['make_dict_value'][master_path] = value
|
ckwargs['make_dict_value'][master_path] = value
|
||||||
if symlink:
|
if symlink:
|
||||||
|
@ -1351,7 +1353,7 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
||||||
ckwargs['make_dict_value'][master_path + 'link'] = value
|
ckwargs['make_dict_value'][master_path + 'link'] = value
|
||||||
if master_path_2:
|
if master_path_2:
|
||||||
with warnings.catch_warnings(record=True) as w:
|
with warnings.catch_warnings(record=True) as w:
|
||||||
ncfg.option(master_path_2).value.set(value)
|
mcfg.option(master_path_2).value.set(value)
|
||||||
ckwargs['make_dict'][master_path_2] = value
|
ckwargs['make_dict'][master_path_2] = value
|
||||||
ckwargs['make_dict_value'][master_path_2] = value
|
ckwargs['make_dict_value'][master_path_2] = value
|
||||||
if symlink:
|
if symlink:
|
||||||
|
@ -1408,11 +1410,12 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
||||||
do('val2', 'val1')
|
do('val2', 'val1')
|
||||||
|
|
||||||
ncfg.property.read_write()
|
ncfg.property.read_write()
|
||||||
|
mcfg.property.read_write()
|
||||||
if req:
|
if req:
|
||||||
name = 'extraoptrequire'
|
name = 'extraoptrequire'
|
||||||
if symlink:
|
if symlink:
|
||||||
name += 'link'
|
name += 'link'
|
||||||
ncfg.option(name).value.set('value')
|
mcfg.option(name).value.set('value')
|
||||||
if 'permissive' in ckwargs and not 'permissive_od' in ckwargs or \
|
if 'permissive' in ckwargs and not 'permissive_od' in ckwargs or \
|
||||||
'propertyerror' in ckwargs and not 'propertyerror_od' in ckwargs:
|
'propertyerror' in ckwargs and not 'propertyerror_od' in ckwargs:
|
||||||
for to_del in ['permissive', 'propertyerror', 'extra_properties']:
|
for to_del in ['permissive', 'propertyerror', 'extra_properties']:
|
||||||
|
@ -1426,7 +1429,7 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
||||||
else:
|
else:
|
||||||
pathwrite = path
|
pathwrite = path
|
||||||
try:
|
try:
|
||||||
func(ncfg, pathread, pathwrite, confread, confwrite, **ckwargs)
|
func(mcfg, ncfg, pathread, pathwrite, confread, confwrite, **ckwargs)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
msg = u'error in function {} for {}'.format(func.__name__, path)
|
msg = u'error in function {} for {}'.format(func.__name__, path)
|
||||||
if multi is True:
|
if multi is True:
|
||||||
|
@ -1441,6 +1444,8 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
||||||
msg += u' (symlink)'
|
msg += u' (symlink)'
|
||||||
print(u'{}: {}'.format(msg, ckwargs))
|
print(u'{}: {}'.format(msg, ckwargs))
|
||||||
raise err
|
raise err
|
||||||
|
if meta:
|
||||||
|
del mcfg
|
||||||
del ncfg
|
del ncfg
|
||||||
|
|
||||||
|
|
||||||
|
@ -1451,7 +1456,7 @@ def check_deref(weakrefs):
|
||||||
assert wrf() is None
|
assert wrf() is None
|
||||||
|
|
||||||
|
|
||||||
def make_conf(options, meta, multi, default, default_multi, require, consistency, callback, symlink):
|
def make_conf(options, multi, default, default_multi, require, consistency, callback, symlink):
|
||||||
weakrefs = []
|
weakrefs = []
|
||||||
dyn = []
|
dyn = []
|
||||||
goptions = []
|
goptions = []
|
||||||
|
@ -1760,7 +1765,7 @@ def test_options(paths):
|
||||||
continue
|
continue
|
||||||
if multi is False and default_multi:
|
if multi is False and default_multi:
|
||||||
continue
|
continue
|
||||||
cfg, weakrefs, dyn = make_conf(paths, meta, multi, default, default_multi, require, consistency, callback, symlink)
|
cfg, weakrefs, dyn = make_conf(paths, multi, default, default_multi, require, consistency, callback, symlink)
|
||||||
if cfg is None:
|
if cfg is None:
|
||||||
continue
|
continue
|
||||||
if dyn:
|
if dyn:
|
||||||
|
|
|
@ -328,7 +328,8 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
||||||
apply_requires=False)
|
apply_requires=False)
|
||||||
self.settings.setproperties(self.option_bag.path,
|
self.settings.setproperties(self.option_bag.path,
|
||||||
props | {prop},
|
props | {prop},
|
||||||
self.option_bag)
|
self.option_bag,
|
||||||
|
self.option_bag.config_bag.context)
|
||||||
|
|
||||||
def pop(self, prop):
|
def pop(self, prop):
|
||||||
"""remove new property for an option"""
|
"""remove new property for an option"""
|
||||||
|
@ -337,12 +338,14 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
||||||
apply_requires=False)
|
apply_requires=False)
|
||||||
self.settings.setproperties(self.option_bag.path,
|
self.settings.setproperties(self.option_bag.path,
|
||||||
props - {prop},
|
props - {prop},
|
||||||
self.option_bag)
|
self.option_bag,
|
||||||
|
self.option_bag.config_bag.context)
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
"""reset all personalised properties"""
|
"""reset all personalised properties"""
|
||||||
option = self.option_bag.option
|
option = self.option_bag.option
|
||||||
self.settings.reset(self.option_bag)
|
self.settings.reset(self.option_bag,
|
||||||
|
self.option_bag.config_bag.context)
|
||||||
|
|
||||||
|
|
||||||
class TiramisuOptionPermissive(CommonTiramisuOption):
|
class TiramisuOptionPermissive(CommonTiramisuOption):
|
||||||
|
@ -734,7 +737,7 @@ class TiramisuContextProperty(TiramisuContext):
|
||||||
def read_only(self):
|
def read_only(self):
|
||||||
"""set configuration to read only mode"""
|
"""set configuration to read only mode"""
|
||||||
settings = self.config_bag.context.cfgimpl_get_settings()
|
settings = self.config_bag.context.cfgimpl_get_settings()
|
||||||
settings.read_only()
|
settings.read_only(self.config_bag.context)
|
||||||
try:
|
try:
|
||||||
del self.config_bag.properties
|
del self.config_bag.properties
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -743,7 +746,7 @@ class TiramisuContextProperty(TiramisuContext):
|
||||||
def read_write(self):
|
def read_write(self):
|
||||||
"""set configuration to read and write mode"""
|
"""set configuration to read and write mode"""
|
||||||
settings = self.config_bag.context.cfgimpl_get_settings()
|
settings = self.config_bag.context.cfgimpl_get_settings()
|
||||||
settings.read_write()
|
settings.read_write(self.config_bag.context)
|
||||||
# #FIXME ?
|
# #FIXME ?
|
||||||
permissives = frozenset(settings.get_context_permissives() | frozenset(['hidden']))
|
permissives = frozenset(settings.get_context_permissives() | frozenset(['hidden']))
|
||||||
settings.set_context_permissives(permissives)
|
settings.set_context_permissives(permissives)
|
||||||
|
@ -772,11 +775,15 @@ class TiramisuContextProperty(TiramisuContext):
|
||||||
|
|
||||||
def set(self, props):
|
def set(self, props):
|
||||||
"""personalise configuration properties"""
|
"""personalise configuration properties"""
|
||||||
self.config_bag.context.cfgimpl_get_settings().set_context_properties(props)
|
context = self.config_bag.context
|
||||||
|
context.cfgimpl_get_settings().set_context_properties(props,
|
||||||
|
context)
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
"""remove configuration properties"""
|
"""remove configuration properties"""
|
||||||
self.config_bag.context.cfgimpl_get_settings().reset(None)
|
context = self.config_bag.context
|
||||||
|
context.cfgimpl_get_settings().reset(None,
|
||||||
|
context)
|
||||||
|
|
||||||
def exportation(self):
|
def exportation(self):
|
||||||
"""export configuration properties"""
|
"""export configuration properties"""
|
||||||
|
|
|
@ -746,13 +746,11 @@ class KernelConfig(_CommonConfig):
|
||||||
raise ConfigError(_('cannot set dynoptiondescription object has root optiondescription'))
|
raise ConfigError(_('cannot set dynoptiondescription object has root optiondescription'))
|
||||||
if force_settings is not None and force_values is not None:
|
if force_settings is not None and force_values is not None:
|
||||||
if isinstance(force_settings, tuple):
|
if isinstance(force_settings, tuple):
|
||||||
self._impl_settings = Settings(self,
|
self._impl_settings = Settings(force_settings[0],
|
||||||
force_settings[0],
|
|
||||||
force_settings[1])
|
force_settings[1])
|
||||||
else:
|
else:
|
||||||
self._impl_settings = force_settings
|
self._impl_settings = force_settings
|
||||||
self._impl_values = Values(self,
|
self._impl_values = Values(force_values)
|
||||||
force_values)
|
|
||||||
else:
|
else:
|
||||||
properties, permissives, values, session_id = get_storages(self,
|
properties, permissives, values, session_id = get_storages(self,
|
||||||
session_id,
|
session_id,
|
||||||
|
@ -760,11 +758,9 @@ class KernelConfig(_CommonConfig):
|
||||||
storage=storage)
|
storage=storage)
|
||||||
if not valid_name(session_id):
|
if not valid_name(session_id):
|
||||||
raise ValueError(_("invalid session ID: {0} for config").format(session_id))
|
raise ValueError(_("invalid session ID: {0} for config").format(session_id))
|
||||||
self._impl_settings = Settings(self,
|
self._impl_settings = Settings(properties,
|
||||||
properties,
|
|
||||||
permissives)
|
permissives)
|
||||||
self._impl_values = Values(self,
|
self._impl_values = Values(values)
|
||||||
values)
|
|
||||||
super().__init__(descr,
|
super().__init__(descr,
|
||||||
weakref.ref(self),
|
weakref.ref(self),
|
||||||
ConfigBag(self),
|
ConfigBag(self),
|
||||||
|
@ -815,11 +811,9 @@ class KernelGroupConfig(_CommonConfig):
|
||||||
self._impl_children = children
|
self._impl_children = children
|
||||||
|
|
||||||
if force_settings is not None and force_values is not None:
|
if force_settings is not None and force_values is not None:
|
||||||
self._impl_settings = Settings(self,
|
self._impl_settings = Settings(force_settings[0],
|
||||||
force_settings[0],
|
|
||||||
force_settings[1])
|
force_settings[1])
|
||||||
self._impl_values = Values(self,
|
self._impl_values = Values(force_values)
|
||||||
force_values)
|
|
||||||
else:
|
else:
|
||||||
properties, permissives, values, session_id = get_storages(self,
|
properties, permissives, values, session_id = get_storages(self,
|
||||||
session_id,
|
session_id,
|
||||||
|
@ -827,11 +821,9 @@ class KernelGroupConfig(_CommonConfig):
|
||||||
storage=storage)
|
storage=storage)
|
||||||
if not valid_name(session_id):
|
if not valid_name(session_id):
|
||||||
raise ValueError(_("invalid session ID: {0} for config").format(session_id))
|
raise ValueError(_("invalid session ID: {0} for config").format(session_id))
|
||||||
self._impl_settings = Settings(self,
|
self._impl_settings = Settings(properties,
|
||||||
properties,
|
|
||||||
permissives)
|
permissives)
|
||||||
self._impl_values = Values(self,
|
self._impl_values = Values(values)
|
||||||
values)
|
|
||||||
|
|
||||||
self._impl_meta = None
|
self._impl_meta = None
|
||||||
super().__init__(_descr,
|
super().__init__(_descr,
|
||||||
|
|
|
@ -319,9 +319,11 @@ undefined = Undefined()
|
||||||
#____________________________________________________________
|
#____________________________________________________________
|
||||||
class Settings(object):
|
class Settings(object):
|
||||||
"``config.Config()``'s configuration options settings"
|
"``config.Config()``'s configuration options settings"
|
||||||
__slots__ = ('context', '_owner', '_p_', '_pp_', '__weakref__')
|
__slots__ = ('_owner', '_p_', '_pp_', '__weakref__')
|
||||||
|
|
||||||
def __init__(self, context, properties, permissives):
|
def __init__(self,
|
||||||
|
properties,
|
||||||
|
permissives):
|
||||||
"""
|
"""
|
||||||
initializer
|
initializer
|
||||||
|
|
||||||
|
@ -333,21 +335,9 @@ class Settings(object):
|
||||||
"""
|
"""
|
||||||
# generic owner
|
# generic owner
|
||||||
self._owner = owners.user
|
self._owner = owners.user
|
||||||
self.context = weakref.ref(context)
|
|
||||||
self._p_ = properties
|
self._p_ = properties
|
||||||
self._pp_ = permissives
|
self._pp_ = permissives
|
||||||
|
|
||||||
def _getcontext(self):
|
|
||||||
"""context could be None, we need to test it
|
|
||||||
context is None only if all reference to `Config` object is deleted
|
|
||||||
(for example we delete a `Config` and we manipulate a reference to
|
|
||||||
old `SubConfig`, `Values`, `Multi` or `Settings`)
|
|
||||||
"""
|
|
||||||
context = self.context()
|
|
||||||
if context is None: # pragma: no cover
|
|
||||||
raise ConfigError(_('the context does not exist anymore'))
|
|
||||||
return context
|
|
||||||
|
|
||||||
#____________________________________________________________
|
#____________________________________________________________
|
||||||
# get properties and permissive methods
|
# get properties and permissive methods
|
||||||
|
|
||||||
|
@ -475,7 +465,7 @@ class Settings(object):
|
||||||
if not current_requires:
|
if not current_requires:
|
||||||
return calc_properties
|
return calc_properties
|
||||||
|
|
||||||
context = self._getcontext()
|
context = option_bag.config_bag.context
|
||||||
all_properties = None
|
all_properties = None
|
||||||
for requires in current_requires:
|
for requires in current_requires:
|
||||||
for require in requires:
|
for require in requires:
|
||||||
|
@ -574,15 +564,18 @@ class Settings(object):
|
||||||
#____________________________________________________________
|
#____________________________________________________________
|
||||||
# set methods
|
# set methods
|
||||||
def set_context_properties(self,
|
def set_context_properties(self,
|
||||||
properties):
|
properties,
|
||||||
|
context):
|
||||||
self.setproperties(None,
|
self.setproperties(None,
|
||||||
properties,
|
properties,
|
||||||
None)
|
None,
|
||||||
|
context)
|
||||||
|
|
||||||
def setproperties(self,
|
def setproperties(self,
|
||||||
path,
|
path,
|
||||||
properties,
|
properties,
|
||||||
option_bag):
|
option_bag,
|
||||||
|
context):
|
||||||
"""save properties for specified path
|
"""save properties for specified path
|
||||||
(never save properties if same has option properties)
|
(never save properties if same has option properties)
|
||||||
"""
|
"""
|
||||||
|
@ -611,7 +604,7 @@ class Settings(object):
|
||||||
self._p_.setproperties(path,
|
self._p_.setproperties(path,
|
||||||
properties)
|
properties)
|
||||||
#values too because of slave values could have a PropertiesOptionError has value
|
#values too because of slave values could have a PropertiesOptionError has value
|
||||||
self._getcontext().cfgimpl_reset_cache(option_bag)
|
context.cfgimpl_reset_cache(option_bag)
|
||||||
if option_bag is not None:
|
if option_bag is not None:
|
||||||
try:
|
try:
|
||||||
del option_bag.properties
|
del option_bag.properties
|
||||||
|
@ -651,14 +644,14 @@ class Settings(object):
|
||||||
' '.join(forbidden_permissives)))
|
' '.join(forbidden_permissives)))
|
||||||
self._pp_.setpermissives(path, permissives)
|
self._pp_.setpermissives(path, permissives)
|
||||||
if option_bag is not None:
|
if option_bag is not None:
|
||||||
self._getcontext().cfgimpl_reset_cache(option_bag)
|
option_bag.config_bag.context.cfgimpl_reset_cache(option_bag)
|
||||||
|
|
||||||
#____________________________________________________________
|
#____________________________________________________________
|
||||||
# reset methods
|
# reset methods
|
||||||
|
|
||||||
def reset(self,
|
def reset(self,
|
||||||
option_bag):
|
option_bag,
|
||||||
# all_properties=False):
|
context):
|
||||||
if option_bag is None:
|
if option_bag is None:
|
||||||
opt = None
|
opt = None
|
||||||
else:
|
else:
|
||||||
|
@ -677,7 +670,7 @@ class Settings(object):
|
||||||
else:
|
else:
|
||||||
path = None
|
path = None
|
||||||
self._p_.delproperties(path)
|
self._p_.delproperties(path)
|
||||||
self._getcontext().cfgimpl_reset_cache(option_bag)
|
context.cfgimpl_reset_cache(option_bag)
|
||||||
|
|
||||||
#____________________________________________________________
|
#____________________________________________________________
|
||||||
# validate properties
|
# validate properties
|
||||||
|
@ -716,7 +709,7 @@ class Settings(object):
|
||||||
value,
|
value,
|
||||||
option_bag):
|
option_bag):
|
||||||
if 'mandatory' in option_bag.config_bag.properties:
|
if 'mandatory' in option_bag.config_bag.properties:
|
||||||
values = self._getcontext().cfgimpl_get_values()
|
values = option_bag.config_bag.context.cfgimpl_get_values()
|
||||||
is_mandatory = False
|
is_mandatory = False
|
||||||
if ('permissive' in option_bag.config_bag.properties) and \
|
if ('permissive' in option_bag.config_bag.properties) and \
|
||||||
'mandatory' in option_bag.config_bag.permissives:
|
'mandatory' in option_bag.config_bag.permissives:
|
||||||
|
@ -751,7 +744,8 @@ class Settings(object):
|
||||||
|
|
||||||
def _read(self,
|
def _read(self,
|
||||||
remove,
|
remove,
|
||||||
append):
|
append,
|
||||||
|
context):
|
||||||
props = self._p_.getproperties(None,
|
props = self._p_.getproperties(None,
|
||||||
default_properties)
|
default_properties)
|
||||||
modified = False
|
modified = False
|
||||||
|
@ -762,17 +756,22 @@ class Settings(object):
|
||||||
props = props | append
|
props = props | append
|
||||||
modified = True
|
modified = True
|
||||||
if modified:
|
if modified:
|
||||||
self.set_context_properties(frozenset(props))
|
self.set_context_properties(frozenset(props),
|
||||||
|
context)
|
||||||
|
|
||||||
def read_only(self):
|
def read_only(self,
|
||||||
|
context):
|
||||||
"convenience method to freeze, hide and disable"
|
"convenience method to freeze, hide and disable"
|
||||||
self._read(ro_remove,
|
self._read(ro_remove,
|
||||||
ro_append)
|
ro_append,
|
||||||
|
context)
|
||||||
|
|
||||||
def read_write(self):
|
def read_write(self,
|
||||||
|
context):
|
||||||
"convenience method to freeze, hide and disable"
|
"convenience method to freeze, hide and disable"
|
||||||
self._read(rw_remove,
|
self._read(rw_remove,
|
||||||
rw_append)
|
rw_append,
|
||||||
|
context)
|
||||||
|
|
||||||
#____________________________________________________________
|
#____________________________________________________________
|
||||||
# default owner methods
|
# default owner methods
|
||||||
|
|
|
@ -27,21 +27,17 @@ class Values(object):
|
||||||
but the values are physicaly located here, in `Values`, wich is also
|
but the values are physicaly located here, in `Values`, wich is also
|
||||||
responsible of a caching utility.
|
responsible of a caching utility.
|
||||||
"""
|
"""
|
||||||
__slots__ = ('context',
|
__slots__ = ('_p_',
|
||||||
'_p_',
|
|
||||||
'__weakref__')
|
'__weakref__')
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
context,
|
|
||||||
storage):
|
storage):
|
||||||
"""
|
"""
|
||||||
Initializes the values's dict.
|
Initializes the values's dict.
|
||||||
|
|
||||||
:param context: the context is the home config's values
|
|
||||||
:param storage: where values or owners are stored
|
:param storage: where values or owners are stored
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.context = weakref.ref(context)
|
|
||||||
# store the storage
|
# store the storage
|
||||||
self._p_ = storage
|
self._p_ = storage
|
||||||
|
|
||||||
|
@ -436,7 +432,6 @@ class Values(object):
|
||||||
_commit=True):
|
_commit=True):
|
||||||
|
|
||||||
context = option_bag.config_bag.context
|
context = option_bag.config_bag.context
|
||||||
setting = context.cfgimpl_get_settings()
|
|
||||||
hasvalue = self._p_.hasvalue(option_bag.path)
|
hasvalue = self._p_.hasvalue(option_bag.path)
|
||||||
|
|
||||||
if hasvalue and 'validator' in option_bag.config_bag.properties:
|
if hasvalue and 'validator' in option_bag.config_bag.properties:
|
||||||
|
|
Loading…
Reference in New Issue