Mercurial > hgrepos > Python > libs > ConfigMix
changeset 426:84d4f82ffe59
Docs: more on jails and sub-jails
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 07 Dec 2021 09:38:33 +0100 |
| parents | 88d8de9310af |
| children | 40be1d25ff1c |
| files | configmix/config.py docs/introduction.rst |
| diffstat | 2 files changed, 19 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/configmix/config.py Tue Dec 07 09:27:44 2021 +0100 +++ b/configmix/config.py Tue Dec 07 09:38:33 2021 +0100 @@ -782,7 +782,11 @@ @property def base(self): - """Ask for the base (aka parent) configuration""" + """Ask for the base (aka parent) configuration". + + This configuration is always unjailed. + + """ return self._base def rebind(self, new_base):
--- a/docs/introduction.rst Tue Dec 07 09:27:44 2021 +0100 +++ b/docs/introduction.rst Tue Dec 07 09:38:33 2021 +0100 @@ -564,12 +564,17 @@ import configmix config = configmix.load("conf10.py") + assert not config.is_jail value = config.getvar_s("tree1.tree2.key4") jailed_config1 = config.jailed(rootpath="tree1.tree2") + assert jailed_config1.is_jail + assert jailed_config1.base is config jvalue1 = jailed_config1.getvar_s("key4") jailed_config2 = config.jailed(root=("tree1", "tree2")) + assert jailed_config2.is_jail + assert jailed_config2.base is config jvalue2 = jailed_config.getvarl_s("key4") assert value == jvalue1 == jvalue2 == "get this as `tree1.tree2.key4'" @@ -582,16 +587,24 @@ configuration. It is possible to get a jailed configuration from an already jailed -configuration:: +configuration. This sub-jail inherits the unjailed base configuration from +the jailed configuration by default. + + :: import configmix config = configmix.load("conf10.py") + assert not config.is_jail value = config.getvar_s("tree1.tree2.key4") jailed_config1 = config.jailed(rootpath="tree1") + assert jailed_config1.is_jail + assert jailed_config2.base is config jailed_config2 = jailed_config2.jailed(rootpath="tree2") + assert jailed_config2.is_jail + assert jailed_config2.base is config jvalue2 = jailed_config.getvarl_s("key4") assert value == jvalue2 == "get this as `tree1.tree2.key4'"
