better support for sqlalchemy storage
This commit is contained in:
@ -74,7 +74,6 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
'dynoptiondescription'))
|
||||
old = child
|
||||
self._add_children(child_names, children)
|
||||
self._cache_paths = None
|
||||
self._cache_consistencies = None
|
||||
# the group_type is useful for filtering OptionDescriptions in a config
|
||||
self._group_type = groups.default
|
||||
@ -167,9 +166,6 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
raise ValueError(_('group_type: {0}'
|
||||
' not allowed').format(group_type))
|
||||
|
||||
def impl_get_group_type(self):
|
||||
return self._group_type
|
||||
|
||||
def _valid_consistency(self, option, value, context, index, submulti_idx):
|
||||
if self._cache_consistencies is None:
|
||||
return True
|
||||
@ -239,7 +235,6 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
:param descr: parent :class:`tiramisu.option.OptionDescription`
|
||||
"""
|
||||
if descr is None:
|
||||
self._cache_paths = None
|
||||
self._cache_consistencies = None
|
||||
self.impl_build_cache_option()
|
||||
descr = self
|
||||
@ -261,8 +256,6 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
|
||||
def _impl_get_suffixes(self, context):
|
||||
callback, callback_params = self.impl_get_callback()
|
||||
if callback_params is None:
|
||||
callback_params = {}
|
||||
values = carry_out_calculation(self, config=context,
|
||||
callback=callback,
|
||||
callback_params=callback_params)
|
||||
@ -275,10 +268,9 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
|
||||
def _impl_search_dynchild(self, name=undefined, context=undefined):
|
||||
ret = []
|
||||
for child in self._impl_st_getchildren():
|
||||
for child in self._impl_st_getchildren(context, only_dyn=True):
|
||||
cname = child.impl_getname()
|
||||
if isinstance(child, DynOptionDescription) and \
|
||||
(name is undefined or name.startswith(cname)):
|
||||
if name is undefined or name.startswith(cname):
|
||||
path = cname
|
||||
for value in child._impl_get_suffixes(context):
|
||||
if name is undefined:
|
||||
@ -296,7 +288,7 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
return child._impl_to_dyn(name, path)
|
||||
|
||||
def _impl_getchildren(self, dyn=True, context=undefined):
|
||||
for child in self._impl_st_getchildren():
|
||||
for child in self._impl_st_getchildren(context):
|
||||
cname = child._name
|
||||
if dyn and child.impl_is_dynoptiondescription():
|
||||
path = cname
|
||||
@ -310,24 +302,30 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
def impl_getchildren(self):
|
||||
return list(self._impl_getchildren())
|
||||
|
||||
def __getattr__(self, name, context=undefined):
|
||||
if name.startswith('_'): # or name.startswith('impl_'):
|
||||
return object.__getattribute__(self, name)
|
||||
return self._getattr(name, context=context)
|
||||
|
||||
|
||||
class DynOptionDescription(OptionDescription):
|
||||
def __init__(self, name, doc, children, requires=None, properties=None,
|
||||
callback=None, callback_params=None):
|
||||
super(DynOptionDescription, self).__init__(name, doc, children,
|
||||
requires, properties)
|
||||
for child in children:
|
||||
if isinstance(child, OptionDescription):
|
||||
if child.impl_get_group_type() != groups.master:
|
||||
raise ConfigError(_('cannot set optiondescription in an '
|
||||
'dynoptiondescription'))
|
||||
for chld in child._impl_getchildren():
|
||||
chld._subdyn = self
|
||||
chld._impl_setsubdyn(self)
|
||||
if isinstance(child, SymLinkOption):
|
||||
raise ConfigError(_('cannot set symlinkoption in an '
|
||||
'dynoptiondescription'))
|
||||
child._subdyn = self
|
||||
super(DynOptionDescription, self).__init__(name, doc, children,
|
||||
requires, properties)
|
||||
child._impl_setsubdyn(self)
|
||||
self.impl_set_callback(callback, callback_params)
|
||||
self.commit()
|
||||
|
||||
def _validate_callback(self, callback, callback_params):
|
||||
if callback is None:
|
||||
@ -346,7 +344,7 @@ class SynDynOptionDescription(object):
|
||||
def __getattr__(self, name, context=undefined):
|
||||
if name in dir(self._opt):
|
||||
return getattr(self._opt, name)
|
||||
return self._opt._getattr(name, self._name, self._suffix, context)
|
||||
return self._opt._getattr(name, suffix=self._suffix, context=context)
|
||||
|
||||
def impl_getname(self):
|
||||
return self._name
|
||||
|
Reference in New Issue
Block a user