recalculate forced value when config.new()

This commit is contained in:
Emmanuel Garette 2018-09-12 22:16:00 +02:00
parent 5bc81f3749
commit e41af1fdce
3 changed files with 22 additions and 6 deletions

View File

@ -3,7 +3,7 @@ from .autopath import do_autopath
do_autopath()
from tiramisu.setting import groups
from tiramisu import Config
from tiramisu import Config, MetaConfig
from tiramisu import ChoiceOption, BoolOption, IntOption, \
StrOption, OptionDescription
from .test_state import _diff_opts, _diff_conf
@ -72,3 +72,14 @@ def test_copy_force_store_value():
conf.option('creole.general.wantref').value.set(True)
assert to_tuple(conf.value.exportation()) == (('creole.general.wantref',), (None,), (True,), ('user',))
assert to_tuple(conf2.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',))
def test_copy_force_store_value_metaconfig():
descr = make_description()
meta = MetaConfig([], optiondescription=descr)
conf = meta.config.new(session_id='conf')
assert to_tuple(conf.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',))
assert to_tuple(meta.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',))
conf.option('creole.general.wantref').value.set(True)
assert to_tuple(conf.value.exportation()) == (('creole.general.wantref',), (None,), (True,), ('user',))
assert to_tuple(meta.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',))

View File

@ -997,8 +997,10 @@ class TiramisuContextConfig(TiramisuContext):
def _c_meta(self):
return Config(self.config_bag.context.cfgimpl_get_meta())
def _m_new(self, name):
return Config(self.config_bag.context.new_config(name))
def _m_new(self,
session_id,
persistent=False):
return Config(self.config_bag.context.new_config(session_id=session_id, persistent=persistent))
def _m_list(self):
return self._g_list()

View File

@ -770,7 +770,7 @@ class KernelConfig(_CommonConfig):
weakref.ref(self),
ConfigBag(self),
None)
if _duplicate is False and (force_settings is None or force_values is None):
if None in [force_settings, force_values]:
self._impl_build_all_caches()
self._impl_name = session_id
@ -986,12 +986,14 @@ class KernelMetaConfig(KernelGroupConfig):
if not _duplicate:
new_children = []
for child_session_id in children:
if not isinstance(child_session_id, str):
raise TypeError(_('MetaConfig with optiondescription must have '
'string has child, not {}').format(child_session_id))
new_children.append(KernelConfig(optiondescription,
persistent=persistent,
session_id=child_session_id))
children = new_children
else:
descr = optiondescription
descr = optiondescription
for child in children:
if not isinstance(child, _CommonConfig):
try:
@ -1016,6 +1018,7 @@ class KernelMetaConfig(KernelGroupConfig):
force_values=force_values,
storage=storage,
_descr=descr)
self._impl_build_all_caches()
def set_value(self,
path,