copy default properties when copy config or create a config in a metaconfig
This commit is contained in:
parent
620e8bbf2e
commit
516a5a7219
|
@ -76,14 +76,13 @@ def test_mod_read_only_write():
|
||||||
'mandatory',
|
'mandatory',
|
||||||
'empty'}
|
'empty'}
|
||||||
#
|
#
|
||||||
config.property.setdefault({'cache'})
|
config.property.setdefault(frozenset(['cache']))
|
||||||
config.property.setdefault(type='read_only', when='append', properties={'disabled'})
|
config.property.setdefault(type='read_only', when='append', properties=frozenset(['disabled']))
|
||||||
config.property.setdefault(type='read_only', when='remove', properties={'hidden'})
|
config.property.setdefault(type='read_only', when='remove', properties=frozenset(['hidden']))
|
||||||
config.property.setdefault(type='read_write', when='append', properties={'disabled',
|
config.property.setdefault(type='read_write', when='append', properties=frozenset(['disabled', 'hidden']))
|
||||||
'hidden'})
|
config.property.setdefault(type='read_write', when='remove', properties=frozenset([]))
|
||||||
config.property.setdefault(type='read_write', when='remove', properties=set([]))
|
raises(ValueError, "config.property.setdefault(type='unknown', when='append', properties=frozenset(['disabled']))")
|
||||||
raises(ValueError, "config.property.setdefault(type='unknown', when='append', properties={'disabled'})")
|
raises(ValueError, "config.property.setdefault(type='read_only', when='unknown', properties=frozenset(['disabled']))")
|
||||||
raises(ValueError, "config.property.setdefault(type='read_only', when='unknown', properties={'disabled'})")
|
|
||||||
raises(TypeError, "config.property.setdefault(type='read_only', when='append', properties=['disabled'])")
|
raises(TypeError, "config.property.setdefault(type='read_only', when='append', properties=['disabled'])")
|
||||||
|
|
||||||
assert config.property.getdefault() == {'cache'}
|
assert config.property.getdefault() == {'cache'}
|
||||||
|
|
|
@ -1047,8 +1047,8 @@ class TiramisuContextProperty(TiramisuContext):
|
||||||
properties: Set[str],
|
properties: Set[str],
|
||||||
type: Optional[str]=None,
|
type: Optional[str]=None,
|
||||||
when: Optional[str]=None) -> None:
|
when: Optional[str]=None) -> None:
|
||||||
if not isinstance(properties, set):
|
if not isinstance(properties, frozenset):
|
||||||
raise TypeError(_('properties must be a set'))
|
raise TypeError(_('properties must be a frozenset'))
|
||||||
setting = self._config_bag.context.cfgimpl_get_settings()
|
setting = self._config_bag.context.cfgimpl_get_settings()
|
||||||
if type is None and when is None:
|
if type is None and when is None:
|
||||||
setting.default_properties = properties
|
setting.default_properties = properties
|
||||||
|
|
|
@ -688,6 +688,11 @@ class _CommonConfig(SubConfig):
|
||||||
duplicated_config.cfgimpl_get_settings()._p_.importation(properties)
|
duplicated_config.cfgimpl_get_settings()._p_.importation(properties)
|
||||||
duplicated_config.cfgimpl_get_settings()._pp_.importation(self.cfgimpl_get_settings(
|
duplicated_config.cfgimpl_get_settings()._pp_.importation(self.cfgimpl_get_settings(
|
||||||
)._pp_.exportation())
|
)._pp_.exportation())
|
||||||
|
duplicated_config.cfgimpl_get_settings().ro_append = self.cfgimpl_get_settings().ro_append
|
||||||
|
duplicated_config.cfgimpl_get_settings().rw_append = self.cfgimpl_get_settings().rw_append
|
||||||
|
duplicated_config.cfgimpl_get_settings().ro_remove = self.cfgimpl_get_settings().ro_remove
|
||||||
|
duplicated_config.cfgimpl_get_settings().rw_remove = self.cfgimpl_get_settings().rw_remove
|
||||||
|
duplicated_config.cfgimpl_get_settings().default_properties = self.cfgimpl_get_settings().default_properties
|
||||||
duplicated_config.cfgimpl_reset_cache(None, None)
|
duplicated_config.cfgimpl_reset_cache(None, None)
|
||||||
if child is not None:
|
if child is not None:
|
||||||
duplicated_config._impl_children.append(child)
|
duplicated_config._impl_children.append(child)
|
||||||
|
@ -1269,6 +1274,11 @@ class KernelMetaConfig(KernelMixConfig):
|
||||||
if new:
|
if new:
|
||||||
config.cfgimpl_get_settings().set_context_properties(self.cfgimpl_get_settings().get_context_properties(), config)
|
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.cfgimpl_get_settings().set_context_permissives(self.cfgimpl_get_settings().get_context_permissives())
|
||||||
|
config.cfgimpl_get_settings().ro_append = self.cfgimpl_get_settings().ro_append
|
||||||
|
config.cfgimpl_get_settings().rw_append = self.cfgimpl_get_settings().rw_append
|
||||||
|
config.cfgimpl_get_settings().ro_remove = self.cfgimpl_get_settings().ro_remove
|
||||||
|
config.cfgimpl_get_settings().rw_remove = self.cfgimpl_get_settings().rw_remove
|
||||||
|
config.cfgimpl_get_settings().default_properties = self.cfgimpl_get_settings().default_properties
|
||||||
|
|
||||||
config._impl_meta = weakref.ref(self)
|
config._impl_meta = weakref.ref(self)
|
||||||
self._impl_children.append(config)
|
self._impl_children.append(config)
|
||||||
|
|
Loading…
Reference in New Issue