when use config.new(), copy properties and permissives

This commit is contained in:
Emmanuel Garette 2018-09-13 06:50:26 +02:00
parent e41af1fdce
commit ccf3f0ae06
2 changed files with 7 additions and 3 deletions

View File

@ -77,9 +77,9 @@ def test_copy_force_store_value():
def test_copy_force_store_value_metaconfig(): def test_copy_force_store_value_metaconfig():
descr = make_description() descr = make_description()
meta = MetaConfig([], optiondescription=descr) meta = MetaConfig([], optiondescription=descr)
meta.property.read_only()
conf = meta.config.new(session_id='conf') conf = meta.config.new(session_id='conf')
assert meta.property.get() == conf.property.get()
assert meta.permissive.get() == conf.permissive.get()
assert to_tuple(conf.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',)) assert to_tuple(conf.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',))
assert to_tuple(meta.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

@ -1133,6 +1133,10 @@ class KernelMetaConfig(KernelGroupConfig):
if config._impl_name in [child._impl_name for child in self._impl_children]: # pragma: no cover if config._impl_name in [child._impl_name for child in self._impl_children]: # pragma: no cover
raise ConflictError(_('config name must be uniq in ' raise ConflictError(_('config name must be uniq in '
'groupconfig for {0}').format(config._impl_name)) 'groupconfig for {0}').format(config._impl_name))
# Copy context properties/permissives
config.cfgimpl_get_settings().set_context_properties(self.cfgimpl_get_settings().get_context_properties(), config)
config.cfgimpl_get_settings().set_context_permissives(self.cfgimpl_get_settings().get_context_permissives())
config._impl_meta = weakref.ref(self) config._impl_meta = weakref.ref(self)
self._impl_children.append(config) self._impl_children.append(config)
return config return config