Bug 33359 - univention.admin.syntax import depends on previous import
univention.admin.syntax import depends on previous import
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 3.2
Other Linux
: P5 normal (vote)
: UCS 4.1-1-errata
Assigned To: Florian Best
Felix Botner
:
: 28179 (view as bug list)
Depends on:
Blocks: 41164
  Show dependency treegraph
 
Reported: 2013-11-13 15:40 CET by Florian Best
Modified: 2016-04-27 15:22 CEST (History)
5 users (show)

See Also:
What kind of report is it?: ---
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:
Ticket number:
Bug group (optional):
Max CVSS v3 score:
best: Patch_Available+


Attachments
patch (8.30 KB, patch)
2016-04-19 11:16 CEST, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2013-11-13 15:40:39 CET
root@master:~# python
Python 2.6.6 (r266:84292, Jul 19 2013, 07:37:05) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import univention.admin.syntax as udm_syntax
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.6/univention/admin/syntax.py", line 37, in <module>
    import univention.admin.modules
  File "/usr/lib/pymodules/python2.6/univention/admin/modules.py", line 978, in <module>
    univention.admin.syntax.import_syntax_files()
AttributeError: 'module' object has no attribute 'syntax'
>>>

Python 2.6.6 (r266:84292, Jul 19 2013, 07:37:05) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import univention.admin.modules as udm_modules
>>> import univention.admin.syntax as udm_syntax
>>>
Comment 1 Philipp Hahn univentionstaff 2013-11-27 15:52:18 CET
*** Bug 28179 has been marked as a duplicate of this bug. ***
Comment 2 Florian Best univentionstaff 2014-02-11 17:22:26 CET
If I had any free votes I would vote for this!

The fix is a one liner:

Index: univention-directory-manager-modules/modules/univention/admin/__init__.py
===================================================================
--- univention-directory-manager-modules/modules/univention/admin/__init__.py      (Revision 47702)
+++ univention-directory-manager-modules/modules/univention/admin/__init__.py      (Arbeitskopie)
@@ -31,7 +31,7 @@
 # <http://www.gnu.org/licenses/>.
 
 import copy, types, string, re
-import mapping
+from univention.admin import mapping
 import univention.config_registry
 import univention.debug

I would also like to see a cleanup of the existing import statements…

FYI: http://www.python.org/dev/peps/pep-0328/
Comment 3 Florian Best univentionstaff 2014-03-11 19:43:51 CET
(In reply to Florian Best from comment #2)
> The fix is a one liner:
Sorry, this was wrong.
Comment 4 Daniel Tröder univentionstaff 2015-09-28 12:33:42 CEST
lo = getMachineConnection()
dn = lo.search(filter="(uid={})".format(username))[0][0]
config = univention.admin.config.config()
univention.admin.modules.update()
usersmod = univention.admin.modules.get("users/user")
lo, position = univention.admin.uldap.getAdminConnection()
univention.admin.modules.init(lo, position, usersmod)
dn_part = dn.partition(",")
user = usersmod.lookup(config, lo, dn_part[0], base=dn_part[-1])[0]
user.open()
user["password"] = password
user.modify()


  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/passwordreset/__init__.py", line 302, in set_password
    user.modify()
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.py", line 1564, in modify
    return super(object, self).modify(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 364, in modify
    return self._modify(modify_childs,ignore_license=ignore_license)
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 839, in _modify
    ml=self._ldap_modlist()
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.py", line 2060, in _ldap_modlist
    pwhistoryPolicy = self.loadPolicyObject('policies/pwhistory')
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 1102, in loadPolicyObject
    self.policyObjects[policy_type]=univention.admin.objects.get(policy_module, None, self.lo, policy_position)
AttributeError: 'module' object has no attribute 'objects'


Does not happen, if "import univention.admin.objects" is before that.
Comment 5 Florian Best univentionstaff 2016-04-19 11:16:43 CEST
Created attachment 7598 [details]
patch

This patch is working :)
Comment 6 Florian Best univentionstaff 2016-04-19 15:12:17 CEST
Fixed in:
Package: univention-directory-manager-modules
Version: 11.0.2-26.1381.201604191507

univention-directory-manager-modules (11.0.2-26):
r68791 | Bug #33359: importing univention.admin modules doesn't depend on previous imports anymore

univention-directory-manager-modules.yaml:
r68792 | YAML Bug #33359
Comment 7 Felix Botner univentionstaff 2016-04-20 14:01:41 CEST
OK - univention-directory-manager-modules
OK - ucs-test-udm*
OK - import univention.admin.syntax as udm_syntax

OK - univention-directory-manager-modules.yaml
Comment 8 Janek Walkenhorst univentionstaff 2016-04-20 15:41:59 CEST
<http://errata.software-univention.de/ucs/4.1/156.html>