suppress _cfgimpl_parent and _cfgimpl_get_path() from SubConfig

This commit is contained in:
Emmanuel Garette 2013-04-05 16:59:48 +02:00
parent 88ea962d82
commit d8b68fa1ec
2 changed files with 5 additions and 24 deletions

View file

@ -31,24 +31,20 @@ from tiramisu.value import Values
class SubConfig(object):
"sub configuration management entry"
__slots__ = ('_cfgimpl_descr', '_cfgimpl_parent', '_cfgimpl_context')
__slots__ = ('_cfgimpl_descr', '_cfgimpl_context')
def __init__(self, descr, parent, context): # FIXME , slots):
def __init__(self, descr, context):
""" Configuration option management master class
:param descr: describes the configuration schema
:type descr: an instance of ``option.OptionDescription``
:param parent: parent's `Config`
:type parent: `Config`
:param context: the current root config
:type context: `Config`
"""
# main option description
self._cfgimpl_descr = descr
# sub option descriptions
self._cfgimpl_parent = parent
self._cfgimpl_context = context
#self._cfgimpl_build(slots)
def cfgimpl_get_context(self):
return self._cfgimpl_context
@ -133,7 +129,7 @@ class SubConfig(object):
"no attribute {2}".format(self.__class__,
opt_or_descr._name,
name))
return SubConfig(opt_or_descr, self, self._cfgimpl_context)
return SubConfig(opt_or_descr, self._cfgimpl_context)
# special attributes
if name.startswith('_cfgimpl_'):
# if it were in __dict__ it would have been found already
@ -157,16 +153,6 @@ class SubConfig(object):
force_properties=force_properties)
return self, path[-1]
def _cfgimpl_get_path(self):
"the path in the attribute access meaning."
#FIXME optimisation
subpath = []
obj = self
while obj._cfgimpl_parent is not None:
subpath.insert(0, obj._cfgimpl_descr._name)
obj = obj._cfgimpl_parent
return ".".join(subpath)
def getkey(self):
return self._cfgimpl_descr.getkey(self)
@ -373,14 +359,12 @@ class Config(SubConfig):
:param descr: describes the configuration schema
:type descr: an instance of ``option.OptionDescription``
:param parent: is None if the ``Config`` is root parent Config otherwise
:type parent: ``Config``
:param context: the current root config
:type context: `Config`
"""
self._cfgimpl_settings = Setting()
self._cfgimpl_values = Values(self)
super(Config, self).__init__(descr, None, self) # , slots)
super(Config, self).__init__(descr, self) # , slots)
self._cfgimpl_build_all_paths()
def _cfgimpl_build_all_paths(self):

View file

@ -574,10 +574,7 @@ def apply_requires(opt, config):
# filters the callbacks
setting = config.cfgimpl_get_settings()
trigger_actions = build_actions(opt._requires)
if isinstance(opt, OptionDescription):
optpath = config._cfgimpl_get_path() + '.' + opt._name
else:
optpath = config.cfgimpl_get_context().cfgimpl_get_description().get_path_by_opt(opt)
optpath = config.cfgimpl_get_context().cfgimpl_get_description().get_path_by_opt(opt)
for requires in trigger_actions.values():
matches = False
for require in requires: