getting stated documentation
This commit is contained in:
@ -531,100 +531,100 @@ class Config(CommonConfig):
|
||||
self.cfgimpl_get_settings().reset_cache(only_expired=only_expired)
|
||||
|
||||
|
||||
class MetaConfig(CommonConfig):
|
||||
__slots__ = ('_impl_children',)
|
||||
#class MetaConfig(CommonConfig):
|
||||
# __slots__ = ('_impl_children',)
|
||||
|
||||
def __init__(self, children, meta=True, session_id=None, is_persistent=False):
|
||||
if not isinstance(children, list):
|
||||
raise ValueError(_("metaconfig's children must be a list"))
|
||||
self._impl_descr = None
|
||||
self._impl_path = None
|
||||
if meta:
|
||||
for child in children:
|
||||
if not isinstance(child, CommonConfig):
|
||||
raise TypeError(_("metaconfig's children "
|
||||
"must be config, not {0}"
|
||||
).format(type(child)))
|
||||
if self._impl_descr is None:
|
||||
self._impl_descr = child.cfgimpl_get_description()
|
||||
elif not self._impl_descr is child.cfgimpl_get_description():
|
||||
raise ValueError(_('all config in metaconfig must '
|
||||
'have the same optiondescription'))
|
||||
if child.cfgimpl_get_meta() is not None:
|
||||
raise ValueError(_("child has already a metaconfig's"))
|
||||
child._impl_meta = self
|
||||
# def __init__(self, children, meta=True, session_id=None, is_persistent=False):
|
||||
# if not isinstance(children, list):
|
||||
# raise ValueError(_("metaconfig's children must be a list"))
|
||||
# self._impl_descr = None
|
||||
# self._impl_path = None
|
||||
# if meta:
|
||||
# for child in children:
|
||||
# if not isinstance(child, CommonConfig):
|
||||
# raise TypeError(_("metaconfig's children "
|
||||
# "must be config, not {0}"
|
||||
# ).format(type(child)))
|
||||
# if self._impl_descr is None:
|
||||
# self._impl_descr = child.cfgimpl_get_description()
|
||||
# elif not self._impl_descr is child.cfgimpl_get_description():
|
||||
# raise ValueError(_('all config in metaconfig must '
|
||||
# 'have the same optiondescription'))
|
||||
# if child.cfgimpl_get_meta() is not None:
|
||||
# raise ValueError(_("child has already a metaconfig's"))
|
||||
# child._impl_meta = self
|
||||
|
||||
self._impl_children = children
|
||||
storage = get_storage(self, session_id, is_persistent)
|
||||
self._impl_settings = Settings(self, storage)
|
||||
self._impl_values = Values(self, storage)
|
||||
self._impl_meta = None
|
||||
self._impl_informations = {}
|
||||
# self._impl_children = children
|
||||
# storage = get_storage(self, session_id, is_persistent)
|
||||
# self._impl_settings = Settings(self, storage)
|
||||
# self._impl_values = Values(self, storage)
|
||||
# self._impl_meta = None
|
||||
# self._impl_informations = {}
|
||||
|
||||
def cfgimpl_get_children(self):
|
||||
return self._impl_children
|
||||
# def cfgimpl_get_children(self):
|
||||
# return self._impl_children
|
||||
|
||||
def cfgimpl_get_context(self):
|
||||
"a meta config is a config wich has a setting, that is itself"
|
||||
return self
|
||||
# def cfgimpl_get_context(self):
|
||||
# "a meta config is a config wich has a setting, that is itself"
|
||||
# return self
|
||||
|
||||
def cfgimpl_reset_cache(self,
|
||||
only_expired=False,
|
||||
only=('values', 'settings')):
|
||||
if 'values' in only:
|
||||
self.cfgimpl_get_values().reset_cache(only_expired=only_expired)
|
||||
if 'settings' in only:
|
||||
self.cfgimpl_get_settings().reset_cache(only_expired=only_expired)
|
||||
for child in self._impl_children:
|
||||
child.cfgimpl_reset_cache(only_expired=only_expired, only=only)
|
||||
# def cfgimpl_reset_cache(self,
|
||||
# only_expired=False,
|
||||
# only=('values', 'settings')):
|
||||
# if 'values' in only:
|
||||
# self.cfgimpl_get_values().reset_cache(only_expired=only_expired)
|
||||
# if 'settings' in only:
|
||||
# self.cfgimpl_get_settings().reset_cache(only_expired=only_expired)
|
||||
# for child in self._impl_children:
|
||||
# child.cfgimpl_reset_cache(only_expired=only_expired, only=only)
|
||||
|
||||
def set_contexts(self, path, value):
|
||||
for child in self._impl_children:
|
||||
try:
|
||||
if not isinstance(child, MetaConfig):
|
||||
setattr(child, path, value)
|
||||
else:
|
||||
child.set_contexts(path, value)
|
||||
except PropertiesOptionError:
|
||||
pass
|
||||
# def set_contexts(self, path, value):
|
||||
# for child in self._impl_children:
|
||||
# try:
|
||||
# if not isinstance(child, MetaConfig):
|
||||
# setattr(child, path, value)
|
||||
# else:
|
||||
# child.set_contexts(path, value)
|
||||
# except PropertiesOptionError:
|
||||
# pass
|
||||
|
||||
def find_first_contexts(self, byname=None, bypath=None, byvalue=None,
|
||||
type_='path', display_error=True):
|
||||
ret = []
|
||||
try:
|
||||
if bypath is None and byname is not None and \
|
||||
self.cfgimpl_get_description() is not None:
|
||||
bypath = self._find(bytype=None, byvalue=None, byname=byname,
|
||||
first=True, type_='path',
|
||||
check_properties=False,
|
||||
display_error=display_error)
|
||||
except ConfigError:
|
||||
pass
|
||||
for child in self._impl_children:
|
||||
try:
|
||||
if not isinstance(child, MetaConfig):
|
||||
if bypath is not None:
|
||||
if byvalue is not None:
|
||||
if getattr(child, bypath) == byvalue:
|
||||
ret.append(child)
|
||||
else:
|
||||
#not raise
|
||||
getattr(child, bypath)
|
||||
ret.append(child)
|
||||
else:
|
||||
ret.append(child.find_first(byname=byname,
|
||||
byvalue=byvalue,
|
||||
type_=type_,
|
||||
display_error=False))
|
||||
else:
|
||||
ret.extend(child.find_first_contexts(byname=byname,
|
||||
bypath=bypath,
|
||||
byvalue=byvalue,
|
||||
type_=type_,
|
||||
display_error=False))
|
||||
except AttributeError:
|
||||
pass
|
||||
return self._find_return_results(ret, display_error)
|
||||
# def find_first_contexts(self, byname=None, bypath=None, byvalue=None,
|
||||
# type_='path', display_error=True):
|
||||
# ret = []
|
||||
# try:
|
||||
# if bypath is None and byname is not None and \
|
||||
# self.cfgimpl_get_description() is not None:
|
||||
# bypath = self._find(bytype=None, byvalue=None, byname=byname,
|
||||
# first=True, type_='path',
|
||||
# check_properties=False,
|
||||
# display_error=display_error)
|
||||
# except ConfigError:
|
||||
# pass
|
||||
# for child in self._impl_children:
|
||||
# try:
|
||||
# if not isinstance(child, MetaConfig):
|
||||
# if bypath is not None:
|
||||
# if byvalue is not None:
|
||||
# if getattr(child, bypath) == byvalue:
|
||||
# ret.append(child)
|
||||
# else:
|
||||
# #not raise
|
||||
# getattr(child, bypath)
|
||||
# ret.append(child)
|
||||
# else:
|
||||
# ret.append(child.find_first(byname=byname,
|
||||
# byvalue=byvalue,
|
||||
# type_=type_,
|
||||
# display_error=False))
|
||||
# else:
|
||||
# ret.extend(child.find_first_contexts(byname=byname,
|
||||
# bypath=bypath,
|
||||
# byvalue=byvalue,
|
||||
# type_=type_,
|
||||
# display_error=False))
|
||||
# except AttributeError:
|
||||
# pass
|
||||
# return self._find_return_results(ret, display_error)
|
||||
|
||||
|
||||
def mandatory_warnings(config):
|
||||
|
Reference in New Issue
Block a user