copy the context in carry_out_calculation

This commit is contained in:
2017-01-11 22:58:01 +01:00
parent e71beac4dc
commit 18d6976183
5 changed files with 31 additions and 8 deletions

View File

@ -148,7 +148,7 @@ 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, False))
tcparams.setdefault(key, []).append((context.duplicate(), False))
else:
# callbk is something link (opt, True|False)
opt, force_permissive = callbk

View File

@ -678,11 +678,14 @@ class _CommonConfig(SubConfig):
return fake_config
def duplicate(self):
config = Config(self._impl_descr)
config = Config(self._impl_descr, _duplicate=True)
session = self.cfgimpl_get_values()._p_.getsession()
config.cfgimpl_get_values()._p_.importation(self.cfgimpl_get_values()._p_.exportation(session))
config.cfgimpl_get_settings()._p_._properties = self.cfgimpl_get_settings()._p_.get_modified_properties()
config.cfgimpl_get_settings()._p_._permissives = self.cfgimpl_get_settings()._p_.get_modified_permissives()
config.cfgimpl_get_values()._p_.importation(self.cfgimpl_get_values()._p_.exportation(
session))
config.cfgimpl_get_settings()._p_._properties = self.cfgimpl_get_settings(
)._p_.get_modified_properties()
config.cfgimpl_get_settings()._p_._permissives = self.cfgimpl_get_settings(
)._p_.get_modified_permissives()
return config
@ -692,7 +695,8 @@ class Config(_CommonConfig):
__slots__ = ('__weakref__', '_impl_test', '_impl_name')
def __init__(self, descr, session_id=None, persistent=False,
name=undefined, force_values=None, force_settings=None):
name=undefined, force_values=None, force_settings=None,
_duplicate=False):
""" Configuration option management master class
:param descr: describes the configuration schema
@ -722,7 +726,7 @@ class Config(_CommonConfig):
self._impl_meta = None
#undocumented option used only in test script
self._impl_test = False
if force_settings is None or force_values is None:
if _duplicate is False and (force_settings is None or force_values is None):
self._impl_build_all_caches()
self._impl_name = name

View File

@ -560,7 +560,8 @@ class Option(OnlyOption):
self.impl_get_display_name())
return ValueError(msg)
error = None
if (display_error and not self._is_warnings_only()) or (display_warnings and self._is_warnings_only()):
if ((display_error and not self._is_warnings_only()) or
(display_warnings and self._is_warnings_only())):
error = calculation_validator(_value)
if not error:
error = self._second_level_validation(_value, self._is_warnings_only())