Le cache des paths est dans l'OptionDescription
Utilisation des slots pour la Config Il faut 566Mo de mémoire pour charger 50 variantes de 100 serveurs chacuns (5000 serveurs en tout). ref #5111
This commit is contained in:
parent
899f864f8d
commit
d00153787d
|
@ -33,11 +33,10 @@ from tiramisu.value import Values
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
class Config(object):
|
class Config(object):
|
||||||
"main configuration management entry"
|
"main configuration management entry"
|
||||||
# __slots__ = ('__dict__', '_cfgimpl_toplevel', '_cfgimpl_descr', '_cfgimpl_subconfigs',
|
__slots__ = ('_cfgimpl_descr', '_cfgimpl_subconfigs',
|
||||||
# '_cfgimpl_parent', '_cfgimpl_all_paths', '_cfgimpl_warnings',
|
'_cfgimpl_parent', '_cfgimpl_warnings', '_cfgimpl_permissive',
|
||||||
# '_cfgimpl_toplevel', '_cfgimpl_slots', '_cfgimpl_build_all_paths')
|
'_cfgimpl_context', '_cfgimpl_settings', '_cfgimpl_values',
|
||||||
_cfgimpl_toplevel = None
|
'_cfgimpl_slots', '_cfgimpl_build_all_paths')
|
||||||
|
|
||||||
def __init__(self, descr, parent=None, context=None, valid_opt_names=True):
|
def __init__(self, descr, parent=None, context=None, valid_opt_names=True):
|
||||||
""" Configuration option management master class
|
""" Configuration option management master class
|
||||||
|
|
||||||
|
@ -62,14 +61,13 @@ class Config(object):
|
||||||
self._cfgimpl_settings = Setting()
|
self._cfgimpl_settings = Setting()
|
||||||
self._cfgimpl_settings.valid_opt_names = valid_opt_names
|
self._cfgimpl_settings.valid_opt_names = valid_opt_names
|
||||||
self._cfgimpl_values = Values(self._cfgimpl_context)
|
self._cfgimpl_values = Values(self._cfgimpl_context)
|
||||||
self._cfgimpl_all_paths = {}
|
#self._cfgimpl_all_paths = {}
|
||||||
else:
|
else:
|
||||||
if context is None:
|
if context is None:
|
||||||
raise ConfigError("cannot find a value for this config")
|
raise ConfigError("cannot find a value for this config")
|
||||||
valid_opt_names = context._cfgimpl_settings.valid_opt_names
|
valid_opt_names = context._cfgimpl_settings.valid_opt_names
|
||||||
"warnings are a great idea, let's make up a better use of it"
|
"warnings are a great idea, let's make up a better use of it"
|
||||||
self._cfgimpl_warnings = []
|
self._cfgimpl_warnings = []
|
||||||
self._cfgimpl_toplevel = self._cfgimpl_get_toplevel()
|
|
||||||
if valid_opt_names:
|
if valid_opt_names:
|
||||||
# some api members shall not be used as option's names !
|
# some api members shall not be used as option's names !
|
||||||
#methods = getmembers(self, ismethod)
|
#methods = getmembers(self, ismethod)
|
||||||
|
@ -82,9 +80,9 @@ class Config(object):
|
||||||
self._cfgimpl_build_all_paths()
|
self._cfgimpl_build_all_paths()
|
||||||
|
|
||||||
def _cfgimpl_build_all_paths(self):
|
def _cfgimpl_build_all_paths(self):
|
||||||
if self._cfgimpl_all_paths == None:
|
# if self._cfgimpl_all_paths == None:
|
||||||
raise ConfigError('cache paths must not be None')
|
# raise ConfigError('cache paths must not be None')
|
||||||
self._cfgimpl_descr.build_cache(self._cfgimpl_all_paths)
|
self._cfgimpl_descr.build_cache() #self._cfgimpl_all_paths)
|
||||||
|
|
||||||
def cfgimpl_get_settings(self):
|
def cfgimpl_get_settings(self):
|
||||||
return self._cfgimpl_context._cfgimpl_settings
|
return self._cfgimpl_context._cfgimpl_settings
|
||||||
|
@ -156,7 +154,8 @@ class Config(object):
|
||||||
def __setattr__(self, name, value):
|
def __setattr__(self, name, value):
|
||||||
"attribute notation mechanism for the setting of the value of an option"
|
"attribute notation mechanism for the setting of the value of an option"
|
||||||
if name.startswith('_cfgimpl_'):
|
if name.startswith('_cfgimpl_'):
|
||||||
self.__dict__[name] = value
|
#self.__dict__[name] = value
|
||||||
|
object.__setattr__(self, name, value)
|
||||||
return
|
return
|
||||||
if '.' in name:
|
if '.' in name:
|
||||||
homeconfig, name = self.cfgimpl_get_home_by_path(name)
|
homeconfig, name = self.cfgimpl_get_home_by_path(name)
|
||||||
|
|
|
@ -424,6 +424,7 @@ class OptionDescription(BaseType, BaseInformation):
|
||||||
self._build()
|
self._build()
|
||||||
self.properties = [] # 'hidden', 'disabled'...
|
self.properties = [] # 'hidden', 'disabled'...
|
||||||
self.informations = {}
|
self.informations = {}
|
||||||
|
self._cache_paths = {}
|
||||||
|
|
||||||
def getdoc(self):
|
def getdoc(self):
|
||||||
return self.doc
|
return self.doc
|
||||||
|
@ -474,7 +475,9 @@ class OptionDescription(BaseType, BaseInformation):
|
||||||
paths.append('.'.join(currpath + [attr]))
|
paths.append('.'.join(currpath + [attr]))
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
def build_cache(self, paths, currpath=None):
|
def build_cache(self, currpath=None):
|
||||||
|
if currpath is None and self._cache_paths != {}:
|
||||||
|
return
|
||||||
if currpath is None:
|
if currpath is None:
|
||||||
currpath = []
|
currpath = []
|
||||||
for option in self._children:
|
for option in self._children:
|
||||||
|
@ -483,10 +486,10 @@ class OptionDescription(BaseType, BaseInformation):
|
||||||
continue
|
continue
|
||||||
if isinstance(option, OptionDescription):
|
if isinstance(option, OptionDescription):
|
||||||
currpath.append(attr)
|
currpath.append(attr)
|
||||||
option.build_cache(paths, currpath=currpath)
|
option.build_cache(currpath=currpath)
|
||||||
currpath.pop()
|
currpath.pop()
|
||||||
else:
|
else:
|
||||||
paths[option] = str('.'.join(currpath + [attr]))
|
self._cache_paths[option] = str('.'.join(currpath + [attr]))
|
||||||
|
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
def set_group_type(self, group_type):
|
def set_group_type(self, group_type):
|
||||||
|
|
Loading…
Reference in New Issue