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/permission.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/permission.py')
-rw-r--r-- | ipalib/plugins/permission.py | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/ipalib/plugins/permission.py b/ipalib/plugins/permission.py index 92203f174..2d300e246 100644 --- a/ipalib/plugins/permission.py +++ b/ipalib/plugins/permission.py @@ -374,20 +374,19 @@ class permission_mod(LDAPUpdate): return dn def exc_callback(self, keys, options, exc, call_func, *call_args, **call_kwargs): - if isinstance(exc, errors.EmptyModlist): - aciupdate = getattr(context, 'aciupdate') - opts = copy.copy(options) - # Clear the aci attributes out of the permission entry - for o in self.obj.aci_attributes + ['all', 'raw', 'rights']: - try: - del opts[o] - except: - pass - - if len(opts) > 0 and not aciupdate: - raise exc - else: - raise exc + if call_func.func_name == 'update_entry': + if isinstance(exc, errors.EmptyModlist): + aciupdate = getattr(context, 'aciupdate') + opts = copy.copy(options) + # Clear the aci attributes out of the permission entry + for o in self.obj.aci_attributes + ['all', 'raw', 'rights']: + try: + del opts[o] + except: + pass + if len(opts) == 0 or aciupdate: + return + raise exc def post_callback(self, ldap, dn, entry_attrs, *keys, **options): # rename the underlying ACI after the change to permission |