From 3ba9cc8eb42c22e1a5b205b6933e3110d2cbd36c Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Thu, 19 Apr 2012 08:06:32 -0400 Subject: 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. --- ipalib/plugins/entitle.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'ipalib/plugins/entitle.py') diff --git a/ipalib/plugins/entitle.py b/ipalib/plugins/entitle.py index 28d2c5dc..6ade854c 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) -- cgit