##// END OF EJS Templates
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
marcink -
r2193:3ea39706 beta
parent child Browse files
Show More
@@ -22,6 +22,7 b' news'
22 22 IP for pull/push logs. - moved all to base controller
23 23 - #415: Adding comment to changeset causes reload.
24 24 Comments are now added via ajax and doesn't reload the page
25 - #374 LDAP config is discarded when LDAP can't be activated
25 26
26 27 fixes
27 28 +++++
@@ -100,25 +100,37 b' class LdapSettingsController(BaseControl'
100 100 _form = LdapSettingsForm([x[0] for x in self.tls_reqcert_choices],
101 101 [x[0] for x in self.search_scope_choices],
102 102 [x[0] for x in self.tls_kind_choices])()
103 # check the ldap lib
104 ldap_active = False
105 try:
106 import ldap
107 ldap_active = True
108 except ImportError:
109 pass
103 110
104 111 try:
105 112 form_result = _form.to_python(dict(request.POST))
113
106 114 try:
107 115
108 116 for k, v in form_result.items():
109 117 if k.startswith('ldap_'):
118 if k == 'ldap_active':
119 v = ldap_active
110 120 setting = RhodeCodeSetting.get_by_name(k)
111 121 setting.app_settings_value = v
112 122 self.sa.add(setting)
113 123
114 124 self.sa.commit()
115 125 h.flash(_('Ldap settings updated successfully'),
116 category='success')
126 category='success')
127 if not ldap_active:
128 #if ldap is missing send an info to user
129 h.flash(_('Unable to activate ldap. The "python-ldap" library '
130 'is missing.'), category='warning')
131
117 132 except (DatabaseError,):
118 133 raise
119 except LdapImportError:
120 h.flash(_('Unable to activate ldap. The "python-ldap" library '
121 'is missing.'), category='warning')
122 134
123 135 except formencode.Invalid, errors:
124 136 e = errors.error_dict or {}
@@ -754,7 +754,7 b' def LdapSettingsForm(tls_reqcert_choices'
754 754 class _LdapSettingsForm(formencode.Schema):
755 755 allow_extra_fields = True
756 756 filter_extra_fields = True
757 pre_validators = [LdapLibValidator]
757 #pre_validators = [LdapLibValidator]
758 758 ldap_active = StringBoolean(if_missing=False)
759 759 ldap_host = UnicodeString(strip=True,)
760 760 ldap_port = Number(strip=True,)
General Comments 0
You need to be logged in to leave comments. Login now