Univention Bugzilla – Attachment 8367 Details for
Bug 43396
Traceback: containers/cn.pathKeys not initialized
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Make PATHS static - modified nowhere and no need to give each instance a copy
0001-Bug-43396-udm-Make-PATHS-static.patch (text/plain), 9.83 KB, created by
Philipp Hahn
on 2017-01-23 12:24:05 CET
(
hide
)
Description:
Make PATHS static - modified nowhere and no need to give each instance a copy
Filename:
MIME Type:
Creator:
Philipp Hahn
Created:
2017-01-23 12:24:05 CET
Size:
9.83 KB
patch
obsolete
>From 1c62c1ede2c4870632dcf0d02c68345c89b5a1f7 Mon Sep 17 00:00:00 2001 >Message-Id: <1c62c1ede2c4870632dcf0d02c68345c89b5a1f7.1485170597.git.hahn@univention.de> >From: Philipp Hahn <hahn@univention.de> >Date: Mon, 23 Jan 2017 11:16:10 +0100 >Subject: [PATCH] Bug #43396 udm: Make PATHS static >Organization: Univention GmbH, Bremen, Germany > >and convert multiple lists to dict() >--- > .../univention/admin/handlers/container/cn.py | 71 +++++++++++++--------- > .../univention/admin/handlers/container/ou.py | 59 ++++++++++-------- > 2 files changed, 76 insertions(+), 54 deletions(-) > >diff --git a/management/univention-directory-manager-modules/modules/univention/admin/handlers/container/cn.py b/management/univention-directory-manager-modules/modules/univention/admin/handlers/container/cn.py >index 3ab5ca6..dcd2281 100644 >--- a/management/univention-directory-manager-modules/modules/univention/admin/handlers/container/cn.py >+++ b/management/univention-directory-manager-modules/modules/univention/admin/handlers/container/cn.py >@@ -209,6 +209,20 @@ mapping.register('description', 'description', None, univention.admin.mapping.Li > class object(univention.admin.handlers.simpleLdap): > module = module > >+ PATH_KEYS = { >+ 'userPath': 'univentionUsersObject', >+ 'groupPath': 'univentionGroupsObject', >+ 'computerPath': 'univentionComputersObject', >+ 'policyPath': 'univentionPolicyObject', >+ 'dnsPath': 'univentionDnsObject', >+ 'dhcpPath': 'univentionDhcpObject', >+ 'networkPath': 'univentionNetworksObject', >+ 'sharePath': 'univentionSharesObject', >+ 'printerPath': 'univentionPrintersObject', >+ 'mailPath': 'univentionMailObject', >+ 'licensePath': 'univentionLicenseObject', >+ } >+ > def open(self): > univention.admin.handlers.simpleLdap.open(self) > >@@ -218,32 +232,29 @@ class object(univention.admin.handlers.simpleLdap): > pathResult = self.lo.get('cn=default containers,cn=univention,' + self.position.getDomain()) > self.default_dn = 'cn=default containers,cn=univention,' + self.position.getDomain() > >- self.pathKeys = ['userPath', 'groupPath', 'computerPath', 'policyPath', 'dnsPath', 'dhcpPath', 'networkPath', 'sharePath', 'printerPath', 'mailPath', 'licensePath'] >- self.ldapKeys = ['univentionUsersObject', 'univentionGroupsObject', 'univentionComputersObject', 'univentionPolicyObject', 'univentionDnsObject', 'univentionDhcpObject', 'univentionNetworksObject', 'univentionSharesObject', 'univentionPrintersObject', 'univentionMailObject', 'univentionLicenseObject'] >- >- for key in self.pathKeys: >- self[key] = '0' >+ for prop in self.PATH_KEYS: >+ self[prop] = '0' > >- for i in range(0, len(self.pathKeys)): >- if pathResult.has_key(self.ldapKeys[i]): >- for j in pathResult[self.ldapKeys[i]]: >+ for prop in self.PATH_KEYS: >+ if prop in pathResult: >+ for j in pathResult[prop]: > if j == self.dn: >- self[self.pathKeys[i]] = '1' >+ self[prop] = '1' > > self.save() > > def _ldap_post_create(self): > changes = [] > >- for i in range(0, len(self.pathKeys)): >- if self.oldinfo[self.pathKeys[i]] != self.info[self.pathKeys[i]]: >- entries = self.lo.getAttr(self.default_dn, self.ldapKeys[i]) >- if self.info[self.pathKeys[i]] == '0': >+ for (prop, attr) in self.PATH_KEYS.items(): >+ if self.oldinfo.get(prop) != self.info.get(prop): >+ entries = self.lo.getAttr(self.default_dn, attr) >+ if self.info[prop] == '0': > if self.dn in entries: >- changes.append((self.ldapKeys[i], self.dn, '')) >+ changes.append((attr, self.dn, '')) > else: > if self.dn not in entries: >- changes.append((self.ldapKeys[i], '', self.dn)) >+ changes.append((attr, '', self.dn)) > > if changes: > self.lo.modify(self.default_dn, changes) >@@ -253,18 +264,6 @@ class object(univention.admin.handlers.simpleLdap): > newdn = 'cn=%s,%s' % (ldap.dn.escape_dn_chars(self.info['name']), self.lo.parentDn(self.dn)) > self.move(newdn) > >- def _ldap_post_modify(self): >- changes = [] >- >- for i in range(0, len(self.pathKeys)): >- if self.oldinfo[self.pathKeys[i]] != self.info[self.pathKeys[i]]: >- if self.info[self.pathKeys[i]] == '0': >- changes.append((self.ldapKeys[i], self.dn, '')) >- else: >- changes.append((self.ldapKeys[i], '', self.dn)) >- if changes: >- self.lo.modify(self.default_dn, changes) >- > def _ldap_post_move(self, olddn): > settings_module = univention.admin.modules.get('settings/directory') > settings_object = univention.admin.objects.get(settings_module, None, self.lo, position='', dn=self.default_dn) >@@ -275,14 +274,26 @@ class object(univention.admin.handlers.simpleLdap): > settings_object[attr].append(self.dn) > settings_object.modify() > >+ def _ldap_post_modify(self): >+ changes = [] >+ >+ for prop, attr in self.PATH_KEYS.items(): >+ if self.oldinfo.get(prop) != self.info.get(prop): >+ if self.info[prop] == '0': >+ changes.append((attr, self.dn, '')) >+ else: >+ changes.append((attr, '', self.dn)) >+ if changes: >+ self.lo.modify(self.default_dn, changes) >+ > def _ldap_pre_remove(self): > changes = [] > > self.open() > >- for i in range(0, len(self.pathKeys)): >- if self.oldinfo[self.pathKeys[i]] == '1': >- changes.append((self.ldapKeys[i], self.dn, '')) >+ for prop, attr in self.PATH_KEYS.items(): >+ if self.oldinfo.get(prop) == '1': >+ changes.append((attr, self.dn, '')) > self.lo.modify(self.default_dn, changes) > > def _ldap_addlist(self): >diff --git a/management/univention-directory-manager-modules/modules/univention/admin/handlers/container/ou.py b/management/univention-directory-manager-modules/modules/univention/admin/handlers/container/ou.py >index 539e81a..83a2843 100644 >--- a/management/univention-directory-manager-modules/modules/univention/admin/handlers/container/ou.py >+++ b/management/univention-directory-manager-modules/modules/univention/admin/handlers/container/ou.py >@@ -190,7 +190,7 @@ property_descriptions = { > layout = [ > Tab(_('General'), _('Basic settings'), layout=[ > Group(_('Organisational unit description'), layout=[ >- ["name", "description"] >+ ["name", "description"], > ]), > ]), > Tab(_('Container settings'), _('Default position when adding objects'), advanced=True, layout=[ >@@ -211,6 +211,20 @@ mapping.register('description', 'description', None, univention.admin.mapping.Li > class object(univention.admin.handlers.simpleLdap): > module = module > >+ PATH_KEYS = { >+ 'userPath': 'univentionUsersObject', >+ 'groupPath': 'univentionGroupsObject', >+ 'computerPath': 'univentionComputersObject', >+ 'policyPath': 'univentionPolicyObject', >+ 'dnsPath': 'univentionDnsObject', >+ 'dhcpPath': 'univentionDhcpObject', >+ 'networkPath': 'univentionNetworksObject', >+ 'sharePath': 'univentionSharesObject', >+ 'printerPath': 'univentionPrintersObject', >+ 'mailPath': 'univentionMailObject', >+ 'licensePath': 'univentionLicenseObject', >+ } >+ > def open(self): > univention.admin.handlers.simpleLdap.open(self) > >@@ -220,17 +234,14 @@ class object(univention.admin.handlers.simpleLdap): > pathResult = self.lo.get('cn=default containers,cn=univention,' + self.position.getDomain()) > self.default_dn = 'cn=default containers,cn=univention,' + self.position.getDomain() > >- self.pathKeys = ['userPath', 'groupPath', 'computerPath', 'policyPath', 'dnsPath', 'dhcpPath', 'networkPath', 'sharePath', 'printerPath', 'mailPath', 'licensePath'] >- self.ldapKeys = ['univentionUsersObject', 'univentionGroupsObject', 'univentionComputersObject', 'univentionPolicyObject', 'univentionDnsObject', 'univentionDhcpObject', 'univentionNetworksObject', 'univentionSharesObject', 'univentionPrintersObject', 'univentionMailObject', 'univentionLicenseObject'] >- >- for key in self.pathKeys: >- self[key] = '0' >+ for prop in self.PATH_KEYS: >+ self[prop] = '0' > >- for i in range(0, len(self.pathKeys)): >- if pathResult.has_key(self.ldapKeys[i]): >- for j in pathResult[self.ldapKeys[i]]: >+ for prop in self.PATH_KEYS: >+ if prop in pathResult: >+ for j in pathResult[prop]: > if j == self.dn: >- self[self.pathKeys[i]] = '1' >+ self[prop] = '1' > > self.save() > >@@ -248,15 +259,15 @@ class object(univention.admin.handlers.simpleLdap): > def _ldap_post_create(self): > changes = [] > >- for i in range(0, len(self.pathKeys)): >- if self.oldinfo[self.pathKeys[i]] != self.info[self.pathKeys[i]]: >- entries = self.lo.getAttr(self.default_dn, self.ldapKeys[i]) >- if self.info[self.pathKeys[i]] == '0': >+ for (prop, attr) in self.PATH_KEYS.items(): >+ if self.oldinfo.get(prop) != self.info.get(prop): >+ entries = self.lo.getAttr(self.default_dn, attr) >+ if self.info[prop] == '0': > if self.dn in entries: >- changes.append((self.ldapKeys[i], self.dn, '')) >+ changes.append((attr, self.dn, '')) > else: > if self.dn not in entries: >- changes.append((self.ldapKeys[i], '', self.dn)) >+ changes.append((attr, '', self.dn)) > > if changes: > self.lo.modify(self.default_dn, changes) >@@ -279,12 +290,12 @@ class object(univention.admin.handlers.simpleLdap): > def _ldap_post_modify(self): > changes = [] > >- for i in range(0, len(self.pathKeys)): >- if self.oldinfo[self.pathKeys[i]] != self.info[self.pathKeys[i]]: >- if self.info[self.pathKeys[i]] == '0': >- changes.append((self.ldapKeys[i], self.dn, '')) >+ for prop, attr in self.PATH_KEYS.items(): >+ if self.oldinfo.get(prop) != self.info.get(prop): >+ if self.info[prop] == '0': >+ changes.append((attr, self.dn, '')) > else: >- changes.append((self.ldapKeys[i], '', self.dn)) >+ changes.append((attr, '', self.dn)) > if changes: > self.lo.modify(self.default_dn, changes) > >@@ -293,9 +304,9 @@ class object(univention.admin.handlers.simpleLdap): > > self.open() > >- for i in range(0, len(self.pathKeys)): >- if self.oldinfo[self.pathKeys[i]] == '1': >- changes.append((self.ldapKeys[i], self.dn, '')) >+ for prop, attr in self.PATH_KEYS.items(): >+ if self.oldinfo.get(prop) == '1': >+ changes.append((attr, self.dn, '')) > self.lo.modify(self.default_dn, changes) > > def _ldap_addlist(self): >-- >2.1.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 43396
: 8367 |
8992