copy/deepcopy could be persistent

This commit is contained in:
Emmanuel Garette 2018-09-12 17:26:12 +02:00
parent 4d3a470e58
commit 10aaf2219f
2 changed files with 8 additions and 1 deletions

View File

@ -979,14 +979,18 @@ class TiramisuContextConfig(TiramisuContext):
def _c_copy(self, def _c_copy(self,
session_id=None, session_id=None,
persistent=False,
storage=None): storage=None):
return Config(self.config_bag.context.duplicate(session_id, return Config(self.config_bag.context.duplicate(session_id,
persistent=persistent,
storage=storage)) storage=storage))
def _c_deepcopy(self, def _c_deepcopy(self,
session_id=None, session_id=None,
persistent=False,
storage=None): storage=None):
return Config(self.config_bag.context.duplicate(session_id, return Config(self.config_bag.context.duplicate(session_id,
persistent=persistent,
storage=storage, storage=storage,
deep=True)) deep=True))

View File

@ -681,6 +681,7 @@ class _CommonConfig(SubConfig):
force_values=None, force_values=None,
force_settings=None, force_settings=None,
storage=None, storage=None,
persistent=False,
deep=False): deep=False):
if isinstance(self, KernelConfig): if isinstance(self, KernelConfig):
config = KernelConfig(self._impl_descr, config = KernelConfig(self._impl_descr,
@ -688,6 +689,7 @@ class _CommonConfig(SubConfig):
session_id=session_id, session_id=session_id,
force_values=force_values, force_values=force_values,
force_settings=force_settings, force_settings=force_settings,
persistent=persistent,
storage=storage) storage=storage)
elif isinstance(self, KernelMetaConfig): elif isinstance(self, KernelMetaConfig):
config = KernelMetaConfig([], config = KernelMetaConfig([],
@ -696,6 +698,7 @@ class _CommonConfig(SubConfig):
session_id=session_id, session_id=session_id,
force_values=force_values, force_values=force_values,
force_settings=force_settings, force_settings=force_settings,
persistent=persistent,
storage=storage) storage=storage)
else: else:
raise Exception('hu?') raise Exception('hu?')
@ -706,7 +709,7 @@ class _CommonConfig(SubConfig):
)._pp_.exportation()) )._pp_.exportation())
if self._impl_meta: if self._impl_meta:
if deep: if deep:
meta = self._impl_meta().duplicate(deep=deep, storage=storage) meta = self._impl_meta().duplicate(deep=deep, storage=storage, persistent=persistent)
meta._impl_children.append(config) meta._impl_children.append(config)
config._impl_meta = weakref.ref(meta) config._impl_meta = weakref.ref(meta)
config = meta config = meta