fixed Issue 1532:mongodb: why to catch connection exceptions? thanks Alan
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user