Bug 48021 - PostReadPyHook module loaded twice
PostReadPyHook module loaded twice
Status: CLOSED DUPLICATE of bug 48958
Product: UCS@school
Classification: Unclassified
Component: Import scripts
UCS@school 4.3
Other Linux
: P5 normal (vote)
: UCS@school 4.3 v6-errata
Assigned To: Daniel Tröder
Sönke Schwardt-Krummrich
https://forge.univention.org/bugzilla...
:
Depends on:
Blocks: 48958 49268
  Show dependency treegraph
 
Reported: 2018-10-19 11:00 CEST by Daniel Tröder
Modified: 2023-03-25 06:42 CET (History)
0 users

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.114
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2018-10-19 11:00:16 CEST
The modules of PostReadPyHooks introduced in Bug #47221 are loaded twice:
* in UserImport
* in BaseReader

That leads to a hook not being able to use super() in __init__, because the second time (for 'all_entries_read') the super class will have changed and the "self" won't be an instance of it anymore.

Example:
---------------------------------------------------------------------------
class PostProcessInputDataHook(PostReadPyHook):
	def __init__(self, *args, **kwargs):
		super(PostProcessInputDataHook, self).__init__(*args, **kwargs)
---------------------------------------------------------------------------

2018-10-19 10:56:46 INFO  user_import.read_input:109  Done reading 5. user: ImportTeacher(name=None, school=None, dn=None)
2018-10-19 10:56:46 ERROR mass_import.import_users:117  super(type, obj): obj must be an instance or subtype of type
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/ucsschool/importer/mass_import/mass_import.py", line 107, in import_users
    imported_users = user_import.read_input()
  File "/usr/lib/pymodules/python2.7/ucsschool/importer/mass_import/user_import.py", line 112, in read_input
    self.call_post_read_hook_all_entries_read(self.imported_users, self.errors)
  File "/usr/lib/pymodules/python2.7/ucsschool/importer/mass_import/user_import.py", line 136, in call_post_read_hook_all_entries_read
    self._post_read_pyhook_cache = pyloader.get_hook_objects(self.connection)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/pyhooks/pyhooks_loader.py", line 126, in get_hook_objects
    pyhook_objs = [pyhook_cls(*args, **kwargs) for pyhook_cls in self.get_hook_classes()]
  File "/usr/share/ucs-school-import/pyhooks/post_process_input_data.py", line 54, in __init__
    super(PostProcessInputDataHook, self).__init__(*args, **kwargs)
TypeError: super(type, obj): obj must be an instance or subtype of type
Comment 1 Daniel Tröder univentionstaff 2018-10-19 11:16:46 CEST
A common cache for running both methods (entry_read and all_entries_read) of PostReadPyHook modules is now used:

f1e6e7b29 Bug #48021: retain stacktrace in traceback
1ac98ab73 Bug #48021: improve docstring
fa1238ed1 Bug #48021: use common cache for PostReadPyHook modules for both methods (entry_read and all_entries_read)

A workaround until this is released, is to use an old-style class "super" call:

-------------------------------------------------------------------------
try:
	super(MyPostReadPyHook, self).__init__(*args, **kwargs)
except TypeError:
	PostReadPyHook.__init__(self, *args, **kwargs)
-------------------------------------------------------------------------

https://git.knut.univention.de/univention/components/ucsschool-hooks/blob/4.2/pyhooks/post_process_input_data.py#L54
Comment 2 Daniel Tröder univentionstaff 2018-10-19 11:31:43 CEST
PS: branch is dtroeder/48021_PostReadPyHook_module_loaded_twice
Comment 3 Daniel Tröder univentionstaff 2019-03-13 17:00:26 CET
Fixed in code for Bug #48958.

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