mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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.
This commit is contained in:
committed by
Martin Kosek
parent
856b9627be
commit
3ba9cc8eb4
@@ -211,9 +211,10 @@ class group_mod(LDAPUpdate):
|
||||
def exc_callback(self, keys, options, exc, call_func, *call_args, **call_kwargs):
|
||||
# Check again for GID requirement in case someone tried to clear it
|
||||
# using --setattr.
|
||||
if isinstance(exc, errors.ObjectclassViolation):
|
||||
if 'gidNumber' in exc.message and 'posixGroup' in exc.message:
|
||||
raise errors.RequirementError(name='gid')
|
||||
if call_func.func_name == 'update_entry':
|
||||
if isinstance(exc, errors.ObjectclassViolation):
|
||||
if 'gidNumber' in exc.message and 'posixGroup' in exc.message:
|
||||
raise errors.RequirementError(name='gid')
|
||||
raise exc
|
||||
|
||||
api.register(group_mod)
|
||||
|
Reference in New Issue
Block a user