Skip to content

Commit

Permalink
Cast default connection port to int.
Browse files Browse the repository at this point in the history
Also use lower name for default connection class
  • Loading branch information
r4fek committed May 13, 2014
1 parent 35cff86 commit 5fa8a63
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions django_mongodb_engine/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,10 @@ def _connect(self):

def pop(name, default=None):
return settings.pop(name) or default

db_name = pop('NAME')
host = pop('HOST')
port = pop('PORT')
port = int(pop('PORT', 27017))
user = pop('USER')
password = pop('PASSWORD')
options = pop('OPTIONS', {})
Expand All @@ -236,12 +237,12 @@ def pop(name, default=None):
"Please use read_preference instead.")

if read_preference:
Connection = MongoReplicaSetClient
connection = MongoReplicaSetClient
else:
Connection = MongoClient
connection = MongoClient

try:
self.connection = Connection(host=host, port=port, **options)
self.connection = connection(host=host, port=port, **options)
self.database = self.connection[db_name]
except TypeError:
exc_info = sys.exc_info()
Expand Down

0 comments on commit 5fa8a63

Please sign in to comment.