diff --git a/tiramisu/autolib.py b/tiramisu/autolib.py index 375dfa2..d263034 100644 --- a/tiramisu/autolib.py +++ b/tiramisu/autolib.py @@ -21,6 +21,7 @@ from .error import PropertiesOptionError, ConfigError, SlaveError from .i18n import _ from .setting import undefined +from .storage import get_default_values_storages, get_default_settings_storages # ____________________________________________________________ @@ -149,7 +150,9 @@ def carry_out_calculation(option, context, callback, callback_params, return undefined if callbk[0] is None: # pragma: optional cover #Not an option, set full context - tcparams.setdefault(key, []).append((context.duplicate(), False)) + tcparams.setdefault(key, []).append((context.duplicate( + force_values=get_default_values_storages(), + force_settings=get_default_settings_storages()), False)) elif callbk[0] == 'index': tcparams.setdefault(key, []).append((index, False)) else: diff --git a/tiramisu/config.py b/tiramisu/config.py index 46310b4..f6d0d81 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -30,7 +30,7 @@ from .option import OptionDescription, Option, SymLinkOption, \ from .option.baseoption import valid_name from .setting import groups, Settings, default_encoding, undefined from .storage import get_storages, get_storage, set_storage, \ - _impl_getstate_setting, get_storages_validation + _impl_getstate_setting, get_default_values_storages from .value import Values, Multi from .i18n import _ @@ -754,13 +754,14 @@ class _CommonConfig(SubConfig): def _gen_fake_values(self, session): fake_config = Config(self._impl_descr, persistent=False, - force_values=get_storages_validation(), + force_values=get_default_values_storages(), force_settings=self.cfgimpl_get_settings()) fake_config.cfgimpl_get_values()._p_.importation(self.cfgimpl_get_values()._p_.exportation(session, fake=True)) return fake_config - def duplicate(self): - config = Config(self._impl_descr, _duplicate=True) + def duplicate(self, force_values=None, force_settings=None): + config = Config(self._impl_descr, _duplicate=True, force_values=force_values, + force_settings=force_settings) session = self.cfgimpl_get_values()._p_.getsession() config.cfgimpl_get_values()._p_.importation(self.cfgimpl_get_values()._p_.exportation( session)) @@ -792,7 +793,10 @@ class Config(_CommonConfig): :type persistent: `boolean` """ if force_settings is not None and force_values is not None: - self._impl_settings = force_settings + if isinstance(force_settings, tuple): + self._impl_settings = Settings(self, force_settings[0], force_settings[1]) + else: + self._impl_settings = force_settings self._impl_values = Values(self, force_values) else: properties, permissives, values = get_storages(self, session_id, persistent) diff --git a/tiramisu/option/baseoption.py b/tiramisu/option/baseoption.py index a4999d2..6d77cf7 100644 --- a/tiramisu/option/baseoption.py +++ b/tiramisu/option/baseoption.py @@ -942,7 +942,7 @@ class Option(OnlyOption): :param load: `True` if we are at the init of the option description :type load: bool """ - if not load and self._get_consistencies() == (): + if not load and not self._has_consistencies(): self._state_consistencies = None elif load and self._state_consistencies is None: del(self._state_consistencies) @@ -1195,6 +1195,9 @@ class SymLinkOption(OnlyOption): def _get_consistencies(self): return () + def _has_consistencies(self): + return False + class DynSymLinkOption(object): __slots__ = ('_dyn', '_opt', '_name') diff --git a/tiramisu/storage/__init__.py b/tiramisu/storage/__init__.py index 58c68ab..cbabe08 100644 --- a/tiramisu/storage/__init__.py +++ b/tiramisu/storage/__init__.py @@ -77,8 +77,8 @@ class StorageType(object): storage_type = StorageType() storage_option_type = StorageType() storage_option_type.set(DEFAULT_STORAGE) -storage_validation = StorageType() -storage_validation.set(DEFAULT_STORAGE) +default_validation = StorageType() +default_validation.set(DEFAULT_STORAGE) def set_storage(type_, name, **kwargs): # pragma: optional cover @@ -122,7 +122,7 @@ def get_storage(type_, session_id, persistent, test): # pragma: optional cover elif type_ == 'config': return storage_type.get().Storage(session_id, persistent, test) else: - return storage_validation.get().Storage(session_id, persistent, test) + return default_validation.get().Storage(session_id, persistent, test) def get_storages(context, session_id, persistent): @@ -149,12 +149,20 @@ def get_storages_option(type_): return imp.StorageOptionDescription -def get_storages_validation(): - imp = storage_validation.get() +def get_default_values_storages(): + imp = default_validation.get() storage = imp.Storage('__validator_storage', persistent=False, test=True) return imp.Values(storage) +def get_default_settings_storages(): + imp = default_validation.get() + storage = imp.Storage('__validator_storage', persistent=False, test=True) + properties = imp.Properties(storage) + permissives = imp.Permissives(storage) + return properties, permissives + + def list_sessions(type_): # pragma: optional cover """List all available session (persistent or not persistent) """ diff --git a/tiramisu/storage/dictionary/option.py b/tiramisu/storage/dictionary/option.py index fecbf84..4a8799b 100644 --- a/tiramisu/storage/dictionary/option.py +++ b/tiramisu/storage/dictionary/option.py @@ -166,6 +166,9 @@ class StorageBase(object): def _get_consistencies(self): return getattr(self, '_consistencies', static_tuple) + def _has_consistencies(self): + return hasattr(self, '_consistencies') + def _set_callback(self, callback, callback_params): val = getattr(self, '_val_call', (None,))[0] if callback_params is None or callback_params == {}: diff --git a/tiramisu/storage/sqlite3/storage.py b/tiramisu/storage/sqlite3/storage.py index 2a4042c..406aa9d 100644 --- a/tiramisu/storage/sqlite3/storage.py +++ b/tiramisu/storage/sqlite3/storage.py @@ -21,6 +21,8 @@ from os.path import basename, splitext, join, isfile import sqlite3 from glob import glob from ..util import SerializeObject +global idx +idx = 0 class Setting(SerializeObject): @@ -93,6 +95,9 @@ class Storage(object): self.execute(permissives_table) def execute(self, sql, params=None, commit=True): + global idx + idx += 1 + print(idx, sql, params) if params is None: params = tuple() self._cursor.execute(sql, params) diff --git a/tiramisu/storage/sqlite3/value.py b/tiramisu/storage/sqlite3/value.py index 034293d..947574e 100644 --- a/tiramisu/storage/sqlite3/value.py +++ b/tiramisu/storage/sqlite3/value.py @@ -152,7 +152,7 @@ class Values(Sqlite3DB): try: nowner = getattr(owners, owner[0]) except AttributeError: - owners.addowner(towner) + owners.addowner(owner[0]) nowner = getattr(owners, owner[0]) if not with_value: return nowner diff --git a/tiramisu/value.py b/tiramisu/value.py index fe6e267..5061763 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -409,9 +409,13 @@ class Values(object): _setting_properties = context.cfgimpl_get_settings()._getproperties(read_write=False) if 'validator' in _setting_properties: session = context.cfgimpl_get_values()._p_.getsession() - fake_context = context._gen_fake_values(session) - fake_values = fake_context.cfgimpl_get_values() - fake_values._setvalue(opt, path, value, index=index) + if opt._has_consistencies(): + fake_context = context._gen_fake_values(session) + fake_values = fake_context.cfgimpl_get_values() + fake_values._setvalue(opt, path, value, index=index) + else: + fake_context = context + fake_values = self props = fake_values.validate(opt, value, path, check_frozen=check_frozen, force_permissive=force_permissive,