Skip to content

Commit

Permalink
Update URI warning in MongoReplicaSetClient.
Browse files Browse the repository at this point in the history
  • Loading branch information
behackett committed Nov 27, 2012
1 parent 76b8b40 commit c5c7bdf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pymongo/mongo_client.py
Expand Up @@ -274,8 +274,9 @@ def __init__(self, host=None, port=None, max_pool_size=10,
raise ConnectionFailure(str(e)) raise ConnectionFailure(str(e))


if db and username is None: if db and username is None:
warnings.warn("database name in URI is being ignored. if you wish to authenticate to %s, " warnings.warn("database name in URI is being ignored. If you wish "
"you must provide a username and password" % (db,)) "to authenticate to %s, you must provide a username "
"and password." % (db,))
if username: if username:
db = db or "admin" db = db or "admin"
if not self[db].authenticate(username, password): if not self[db].authenticate(username, password):
Expand Down
5 changes: 3 additions & 2 deletions pymongo/mongo_replica_set_client.py
Expand Up @@ -433,8 +433,9 @@ def __init__(self, hosts_or_uri=None, max_pool_size=10,
raise ConnectionFailure(str(e)) raise ConnectionFailure(str(e))


if db_name and username is None: if db_name and username is None:
warnings.warn("must provide a username and password " warnings.warn("database name in URI is being ignored. If you wish "
"to authenticate to %s" % (db_name,)) "to authenticate to %s, you must provide a username "
"and password." % (db_name,))
if username: if username:
db_name = db_name or 'admin' db_name = db_name or 'admin'
if not self[db_name].authenticate(username, password): if not self[db_name].authenticate(username, password):
Expand Down

0 comments on commit c5c7bdf

Please sign in to comment.