# HG changeset patch # User Franz Glasner # Date 1637324813 -3600 # Node ID af367e1d09503051216f091958167b3e482c092d # Parent 6a5aea02f3d0b4525fba436a1b5bd526a2e2e966 Allow to rebind a jailed configuration to another "similar" base diff -r 6a5aea02f3d0 -r af367e1d0950 configmix/config.py --- a/configmix/config.py Fri Nov 19 12:40:23 2021 +0100 +++ b/configmix/config.py Fri Nov 19 13:26:53 2021 +0100 @@ -716,7 +716,6 @@ def __init__(self, config, *path): super(_JailedConfiguration, self).__init__() - self._base = config self._path = path if path: self._pathstr = \ @@ -725,12 +724,26 @@ + Configuration._HIER_SEPARATOR else: self._pathstr = '' + self.rebind(config) + + def rebind(self, new_base): + """Bind the jail to a new unjailed configuration `new_base`. + + The new configuration base also must have an existing path to + the root. + + :param Configuration new_base: the new base + + """ + if new_base.is_jail: + raise TypeError("can only bind to an unjailed configuration") + self._base = new_base # # Early error out if the chroot does not exist but allow # degenerated case if `self._path` is empty. # if self._path: - self._base.getvarl(*self._path) + new_base.getvarl(*self._path) def getvarl(self, *path, **kwds): return self._base.getvarl(*(self._path + path), **kwds)