File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -213,7 +213,7 @@ def pop(name, default=None):
213
213
214
214
db_name = pop ('NAME' )
215
215
host = pop ('HOST' )
216
- port = int ( pop ('PORT' , 27017 ) )
216
+ port = pop ('PORT' , 27017 )
217
217
user = pop ('USER' )
218
218
password = pop ('PASSWORD' )
219
219
options = pop ('OPTIONS' , {})
@@ -238,15 +238,27 @@ def pop(name, default=None):
238
238
if read_preference :
239
239
options ['read_preference' ] = ReadPreference .SECONDARY
240
240
warnings .warn ("slave_okay has been deprecated. "
241
- "Please use read_preference instead." )
241
+ "Please use read_preference instead." )
242
242
243
243
if replicaset :
244
- connection = MongoReplicaSetClient
244
+ connection_class = MongoReplicaSetClient
245
245
else :
246
- connection = MongoClient
246
+ connection_class = MongoClient
247
+
248
+ conn_options = dict (
249
+ host = host ,
250
+ port = int (port ),
251
+ max_pool_size = None ,
252
+ document_class = dict ,
253
+ tz_aware = False ,
254
+ _connect = True ,
255
+ auto_start_request = True ,
256
+ safe = False
257
+ )
258
+ conn_options .update (options )
247
259
248
260
try :
249
- self .connection = connection ( host = host , port = port , ** options )
261
+ self .connection = connection_class ( ** conn_options )
250
262
self .database = self .connection [db_name ]
251
263
except TypeError :
252
264
exc_info = sys .exc_info ()
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ def test_generic_field(self):
55
55
self .assertEqual (RawModel .objects .get (id = id ).raw , obj )
56
56
57
57
def test_databasewrapper_api (self ):
58
- from pymongo .connection import Connection
58
+ from pymongo .mongo_client import MongoClient
59
59
from pymongo .database import Database
60
60
from pymongo .collection import Collection
61
61
from random import shuffle
@@ -70,7 +70,7 @@ def test_databasewrapper_api(self):
70
70
lambda : self .assertIsInstance (wrapper .get_collection ('foo' ),
71
71
Collection ),
72
72
lambda : self .assertIsInstance (wrapper .database , Database ),
73
- lambda : self .assertIsInstance (wrapper .connection , Connection ),
73
+ lambda : self .assertIsInstance (wrapper .connection , MongoClient ),
74
74
]
75
75
shuffle (calls )
76
76
for call in calls :
You can’t perform that action at this time.
0 commit comments