[ldap] make instance still usable if we can't contact ldap server stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 12 Nov 2010 13:47:26 +0100
branchstable
changeset 6693 65bd93b72f1e
parent 6692 bbc3f7c9f8d9
child 6694 d9eac4fd57dc
[ldap] make instance still usable if we can't contact ldap server
server/sources/ldapuser.py
--- a/server/sources/ldapuser.py	Fri Nov 05 18:48:07 2010 +0100
+++ b/server/sources/ldapuser.py	Fri Nov 12 13:47:26 2010 +0100
@@ -369,8 +369,14 @@
         try:
             results = self._query_cache[rqlkey]
         except KeyError:
-            results = self.rqlst_search(session, rqlst, args)
-            self._query_cache[rqlkey] = results
+            try:
+                results = self.rqlst_search(session, rqlst, args)
+                self._query_cache[rqlkey] = results
+            except ldap.SERVER_DOWN:
+                # cant connect to server
+                msg = session._("can't connect to source %s, some data may be missing")
+                session.set_shared_data('sources_error', msg % self.uri)
+                return []
         return results
 
     def rqlst_search(self, session, rqlst, args):