iredadmin-ose / libs / ldaplib / admin.py

Diff from to

libs/ldaplib/admin.py

     # Get preferredLanguage.
     def getPreferredLanguage(self, dn):
         dn = ldap.filter.escape_filter_chars(dn)
-        self.lang = self.conn.search_s(
+        lang = self.conn.search_s(
             dn,
             ldap.SCOPE_BASE,
             attrlist=['preferredLanguage'],
         )
-        if 'preferredLanguage' in self.lang[0][1].keys():
-            lang = self.lang[0][1]['preferredLanguage'][0]
+        if 'preferredLanguage' in lang[0][1].keys():
+            lang = lang[0][1]['preferredLanguage'][0]
         else:
             lang = web.ctx.lang
         return lang
         mod_attrs = []
         if self.profile_type == 'general':
             # Get preferredLanguage.
-            self.lang = web.safestr(data.get('preferredLanguage', 'en_US'))
-            mod_attrs += [(ldap.MOD_REPLACE, 'preferredLanguage', self.lang)]
+            lang = web.safestr(data.get('preferredLanguage', 'en_US'))
+            mod_attrs += [(ldap.MOD_REPLACE, 'preferredLanguage', lang)]
 
             # Get cn.
             cn = data.get('cn', None)
             try:
                 # Modify profiles.
                 self.conn.modify_s(self.dn, mod_attrs)
-                if session.get('username') == self.mail:
-                    session['lang'] = self.lang
+                if session.get('username') == self.mail and \
+                   session.get('lang', 'en_US') != lang:
+                    session['lang'] = lang
             except ldap.LDAPError, e:
                 return (False, ldaputils.getExceptionDesc(e))
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.