Bug 41576 - ucsschool-import: remove hook functions in UserImport
ucsschool-import: remove hook functions in UserImport
Status: CLOSED DUPLICATE of bug 41572
Product: UCS@school
Classification: Unclassified
Component: Import scripts
UCS@school 4.1 R2
Other Linux
: P5 minor (vote)
: UCS@school 4.1.x
Assigned To: Sönke Schwardt-Krummrich
Daniel Tröder
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-06-15 12:18 CEST by Sönke Schwardt-Krummrich
Modified: 2023-03-25 06:40 CET (History)
3 users (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Cleanup
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sönke Schwardt-Krummrich univentionstaff 2016-06-15 12:18:30 CEST
The hook functions directly within the UserImport class (ucs-school-import/modules/ucsschool/importer/mass_import/user_import.py) are not that flexible as expected. 
The PyHooks cover the same benefits and are much more flexible (stackable, other packages can install hooks without subclassing existing files).


+++ This bug was initially created as a clone of Bug #41354 +++

The UserImport object has a "connection" attribute. It is documented in the docstring:


def create_and_modify_hook(self, user, hook_time):
	"""
	Run code before or after creating or modifying a user.

	IMPLEMENT ME if you want to use a hook. You'll have full access to the
	data being saved to LDAP. It is much faster than running executables
	from /usr/share/ucs-school-import/hooks/*.

	* See user.action to know which action it is ("A" or "M").
	* With action=A, if hook_time=pre the ImportUser does not exist in
	LDAP, yet. user.dn will be None. If hook_time=post user will be a
	opened ImportUser, loaded from LDAP.
	* With action=M, user is always a opened ImportUser, loaded from LDAP.
	* Use self.connection if you need a LDAP connection.

	:param user: ImportUser
	:param hook_time: str: either "pre" or "post"
	:return: None
	"""
	pass

def delete_hook(self, user, hook_time):
	"""
	Run code before or after deleting a user.

	IMPLEMENT ME if you want to use a hook. You'll have full access to the
	data being saved to LDAP. It is much faster than running executables
	from /usr/share/ucs-school-import/hooks/*.

	* user is a opened ImportUser, loaded from LDAP.
	* Use self.connection if you need a LDAP connection.

	:param user: ImportUser
	:param hook_time: str: either "pre" or "post"
	:return: None
	"""
	pass
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2016-06-15 12:19:19 CEST
The hook functions in UserImport class are deprecated and will be removed soon!
Comment 2 Sönke Schwardt-Krummrich univentionstaff 2016-10-06 11:51:16 CEST
Functions have already been renamed in 41354 and removed/refactored via 41572.

*** This bug has been marked as a duplicate of bug 41572 ***