Skip to content

Commit 5fa8a63

Browse files
committed
Cast default connection port to int.
Also use lower name for default connection class
1 parent 35cff86 commit 5fa8a63

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

django_mongodb_engine/base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,10 @@ def _connect(self):
209209

210210
def pop(name, default=None):
211211
return settings.pop(name) or default
212+
212213
db_name = pop('NAME')
213214
host = pop('HOST')
214-
port = pop('PORT')
215+
port = int(pop('PORT', 27017))
215216
user = pop('USER')
216217
password = pop('PASSWORD')
217218
options = pop('OPTIONS', {})
@@ -236,12 +237,12 @@ def pop(name, default=None):
236237
"Please use read_preference instead.")
237238

238239
if read_preference:
239-
Connection = MongoReplicaSetClient
240+
connection = MongoReplicaSetClient
240241
else:
241-
Connection = MongoClient
242+
connection = MongoClient
242243

243244
try:
244-
self.connection = Connection(host=host, port=port, **options)
245+
self.connection = connection(host=host, port=port, **options)
245246
self.database = self.connection[db_name]
246247
except TypeError:
247248
exc_info = sys.exc_info()

0 commit comments

Comments
 (0)