need new settings when create fake_config
This commit is contained in:
@ -106,6 +106,7 @@ def _impl_getstate_setting():
|
||||
def get_storage(type_, session_id, persistent, test): # pragma: optional cover
|
||||
"""all used when __setstate__ a Config
|
||||
"""
|
||||
#FIXME ca sert ???
|
||||
if type_ == 'option':
|
||||
return storage_option_type.get().Storage(session_id, persistent, test)
|
||||
elif type_ == 'config':
|
||||
@ -114,7 +115,7 @@ def get_storage(type_, session_id, persistent, test): # pragma: optional cover
|
||||
return storage_validation.get().Storage(session_id, persistent, test)
|
||||
|
||||
|
||||
def get_storages(context, session_id, persistent, only_value=False):
|
||||
def get_storages(context, session_id, persistent):
|
||||
def gen_id(config):
|
||||
return str(id(config)) + str(time()) + str(randint(0, 500))
|
||||
|
||||
@ -122,10 +123,7 @@ def get_storages(context, session_id, persistent, only_value=False):
|
||||
session_id = gen_id(context)
|
||||
imp = storage_type.get()
|
||||
storage = imp.Storage(session_id, persistent)
|
||||
if only_value:
|
||||
settings = None
|
||||
else:
|
||||
settings = imp.Settings(storage)
|
||||
settings = imp.Settings(storage)
|
||||
values = imp.Values(storage)
|
||||
try:
|
||||
return settings, values
|
||||
@ -143,8 +141,8 @@ def get_storages_option(type_):
|
||||
|
||||
def get_storages_validation():
|
||||
imp = storage_validation.get()
|
||||
storage = imp.Storage('pouet', persistent=False, test=True)
|
||||
return imp.Settings(storage), imp.Values(storage)
|
||||
storage = imp.Storage('__validator_storage', persistent=False, test=True)
|
||||
return imp.Values(storage)
|
||||
|
||||
|
||||
def list_sessions(type_): # pragma: optional cover
|
||||
|
@ -365,6 +365,8 @@ class StorageOptionDescription(StorageBase):
|
||||
raise AttributeError(_('no option for path {0}').format(path))
|
||||
|
||||
def impl_get_path_by_opt(self, opt):
|
||||
if self._cache_paths is None:
|
||||
raise ConfigError(_('use impl_get_path_by_opt only with root OptionDescription'))
|
||||
try:
|
||||
return self._cache_paths[1][self._cache_paths[0].index(opt)]
|
||||
except ValueError: # pragma: optional cover
|
||||
|
@ -213,9 +213,8 @@ class _Consistency(SqlAlchemyBase):
|
||||
|
||||
def __init__(self, func, all_cons_opts, params):
|
||||
self.func = func
|
||||
for option in all_cons_opts:
|
||||
for option in all_cons_opts[1:]:
|
||||
option._consistencies.append(self)
|
||||
print type(option._consistencies)
|
||||
self.params = params
|
||||
|
||||
|
||||
@ -278,6 +277,7 @@ class _Base(SqlAlchemyBase):
|
||||
_calc_props = relationship("_CalcProperties", collection_class=set)
|
||||
_calc_properties = association_proxy("_calc_props", "name")
|
||||
_warnings_only = Column(Boolean)
|
||||
_allow_empty_list = Column(Boolean)
|
||||
_readonly = Column(Boolean, default=False)
|
||||
_consistencies = relationship('_Consistency', secondary=consistency_table,
|
||||
backref=backref('options',
|
||||
@ -295,13 +295,15 @@ class _Base(SqlAlchemyBase):
|
||||
|
||||
#def __init__(self):
|
||||
def __init__(self, name, multi, warnings_only, doc, extra, calc_properties,
|
||||
requires, properties, opt=undefined):
|
||||
requires, properties, allow_empty_list, opt=undefined):
|
||||
util.session.add(self)
|
||||
self._name = name
|
||||
if multi is not undefined:
|
||||
self._multi = multi
|
||||
if warnings_only is not undefined:
|
||||
self._warnings_only = warnings_only
|
||||
if allow_empty_list is not undefined:
|
||||
self._allow_empty_list = allow_empty_list
|
||||
if doc is not undefined:
|
||||
self._informations = {'doc': doc}
|
||||
if opt is not undefined:
|
||||
@ -405,6 +407,12 @@ class _Base(SqlAlchemyBase):
|
||||
def impl_is_submulti(self):
|
||||
return self._multi == 2
|
||||
|
||||
def impl_allow_empty_list(self):
|
||||
try:
|
||||
return self._allow_empty_list
|
||||
except AttributeError:
|
||||
return undefined
|
||||
|
||||
def _is_warnings_only(self):
|
||||
return self._warnings_only
|
||||
|
||||
@ -479,6 +487,9 @@ class StorageOptionDescription(object):
|
||||
ret = util.session.query(Cache).filter_by(descr=self.id,
|
||||
option=opt.id).first()
|
||||
if ret is None:
|
||||
ret = util.session.query(Cache).filter_by(descr=self.id).first()
|
||||
if ret is None:
|
||||
raise ConfigError(_('use impl_get_path_by_opt only with root OptionDescription'))
|
||||
raise AttributeError(_('no option {0} found').format(opt))
|
||||
return ret.path
|
||||
|
||||
|
Reference in New Issue
Block a user