diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-12 23:40:36 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-12 23:40:36 +0000 |
commit | 7db3aae1b26588b3650dae442b07dca0f33ab0c8 (patch) | |
tree | 4ab00720041d20b09f87ff74abc965a3f307746d /ipalib/plugable.py | |
parent | 64054a673c23b543450741fa11333bc627efeca3 (diff) | |
download | freeipa.git-7db3aae1b26588b3650dae442b07dca0f33ab0c8.tar.gz freeipa.git-7db3aae1b26588b3650dae442b07dca0f33ab0c8.tar.xz freeipa.git-7db3aae1b26588b3650dae442b07dca0f33ab0c8.zip |
123: API.finalize() now raises AssetionError if called more than once; added corresponding unit tests
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r-- | ipalib/plugable.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 8241d8ea..71f03357 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -480,6 +480,8 @@ class Registrar(ReadOnly): class API(ReadOnly): + __finalized = False + def __init__(self, *allowed): self.__keys = tuple(b.__name__ for b in allowed) self.register = Registrar(*allowed) @@ -489,6 +491,7 @@ class API(ReadOnly): """ Finalize the registration, instantiate the plugins. """ + assert not self.__finalized, 'finalize() can only be called once' d = {} def plugin_iter(base, classes): for cls in classes: @@ -506,6 +509,7 @@ class API(ReadOnly): plugin.__lock__() assert plugin.__islocked__() is True assert plugin.api is self + object.__setattr__(self, '_API__finalized', True) def __iter__(self): for key in self.__keys: |