diff options
author | Jan Cholasta <jcholast@redhat.com> | 2012-04-19 08:06:32 -0400 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-04-26 09:00:30 +0200 |
commit | 3ba9cc8eb42c22e1a5b205b6933e3110d2cbd36c (patch) | |
tree | 5d9025bddb28f6be6aecf853e37d13aa1b78dc0f /ipalib/plugins/entitle.py | |
parent | 856b9627beaca89fde6904cdea398ac817faf321 (diff) | |
download | freeipa-3ba9cc8eb42c22e1a5b205b6933e3110d2cbd36c.tar.gz freeipa-3ba9cc8eb42c22e1a5b205b6933e3110d2cbd36c.tar.xz freeipa-3ba9cc8eb42c22e1a5b205b6933e3110d2cbd36c.zip |
Refactor exc_callback invocation.
Replace _call_exc_callbacks with a function wrapper, which will automatically
call exception callbacks when an exception is raised from the function. This
removes the need to specify the function and its arguments twice (once in the
function call itself and once in _call_exc_callbacks).
Add some extra checks to existing exception callbacks.
Diffstat (limited to 'ipalib/plugins/entitle.py')
-rw-r--r-- | ipalib/plugins/entitle.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ipalib/plugins/entitle.py b/ipalib/plugins/entitle.py index 28d2c5dc8..6ade854c3 100644 --- a/ipalib/plugins/entitle.py +++ b/ipalib/plugins/entitle.py @@ -642,12 +642,12 @@ class entitle_import(LDAPUpdate): If we are adding the first entry there are no updates so EmptyModlist will get thrown. Ignore it. """ - if isinstance(exc, errors.EmptyModlist): - if not getattr(context, 'entitle_import', False): - raise exc - return (call_args, {}) - else: - raise exc + if call_func.func_name == 'update_entry': + if isinstance(exc, errors.EmptyModlist): + if not getattr(context, 'entitle_import', False): + raise exc + return (call_args, {}) + raise exc def execute(self, *keys, **options): super(entitle_import, self).execute(*keys, **options) @@ -729,9 +729,10 @@ class entitle_sync(LDAPUpdate): return dn def exc_callback(self, keys, options, exc, call_func, *call_args, **call_kwargs): - if isinstance(exc, errors.EmptyModlist): - # If there is nothing to change we are already synchronized. - return + if call_func.func_name == 'update_entry': + if isinstance(exc, errors.EmptyModlist): + # If there is nothing to change we are already synchronized. + return raise exc api.register(entitle_sync) |