new can create a metaconfig too

This commit is contained in:
Emmanuel Garette 2018-09-13 09:17:38 +02:00
parent e6cbcde927
commit 77a77dd01c
2 changed files with 19 additions and 8 deletions

View file

@ -1001,8 +1001,11 @@ class TiramisuContextConfig(TiramisuContext):
def _m_new(self, def _m_new(self,
session_id, session_id,
persistent=False): persistent=False,
return Config(self.config_bag.context.new_config(session_id=session_id, persistent=persistent)) type='config'):
return Config(self.config_bag.context.new_config(session_id=session_id,
persistent=persistent,
type_=type))
def _m_pop(self, def _m_pop(self,
session_id): session_id):

View file

@ -1125,14 +1125,22 @@ class KernelMetaConfig(KernelGroupConfig):
def new_config(self, def new_config(self,
session_id, session_id,
type_='config',
persistent=False): persistent=False):
config = KernelConfig(self._impl_descr, if session_id in [child._impl_name for child in self._impl_children]: # pragma: no cover
session_id=session_id,
persistent=persistent)
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(session_id))
if type_ == 'config':
config = KernelConfig(self._impl_descr,
session_id=session_id,
persistent=persistent)
elif type_ == 'metaconfig':
config = KernelMetaConfig([],
optiondescription=self._impl_descr,
session_id=session_id,
persistent=persistent)
else:
raise ConfigError(_('unknown type {}').format(type_))
# Copy context properties/permissives # 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_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())