fixed Issue 1532:mongodb: why to catch connection exceptions? thanks Alan

This commit is contained in:
mdipierro
2013-06-16 06:52:17 -05:00
parent 4a0bc28b09
commit e7724f9017
2 changed files with 8 additions and 12 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.5.1-stable+timestamp.2013.06.16.03.25.54
Version 2.5.1-stable+timestamp.2013.06.16.06.51.32
+7 -11
View File
@@ -5223,18 +5223,14 @@ class MongoDBAdapter(NoSQLAdapter):
m = {"database" : m[1]}
if m.get('database')==None:
raise SyntaxError("Database is required!")
def connector(uri=self.uri,m=m):
try:
# Connection() is deprecated
if hasattr(self.driver, "MongoClient"):
Connection = self.driver.MongoClient
else:
Connection = self.driver.Connection
return Connection(uri)[m.get('database')]
except self.driver.errors.ConnectionFailure:
inst = sys.exc_info()[1]
raise SyntaxError("The connection to " +
uri + " could not be made")
# Connection() is deprecated
if hasattr(self.driver, "MongoClient"):
Connection = self.driver.MongoClient
else:
Connection = self.driver.Connection
return Connection(uri)[m.get('database')]
self.reconnect(connector,cursor=False)