Merge pull request #737 from wcdolphin/master

Make 'db' argument to connection optional
This commit is contained in:
Yohan Graterol 2014-08-22 08:24:03 -05:00
commit 05339e184f

View File

@ -18,7 +18,7 @@ _connections = {}
_dbs = {} _dbs = {}
def register_connection(alias, name, host=None, port=None, def register_connection(alias, name=None, host=None, port=None,
read_preference=False, read_preference=False,
username=None, password=None, authentication_source=None, username=None, password=None, authentication_source=None,
**kwargs): **kwargs):
@ -40,7 +40,7 @@ def register_connection(alias, name, host=None, port=None,
global _connection_settings global _connection_settings
conn_settings = { conn_settings = {
'name': name, 'name': name or 'test',
'host': host or 'localhost', 'host': host or 'localhost',
'port': port or 27017, 'port': port or 27017,
'read_preference': read_preference, 'read_preference': read_preference,
@ -144,7 +144,7 @@ def get_db(alias=DEFAULT_CONNECTION_NAME, reconnect=False):
return _dbs[alias] return _dbs[alias]
def connect(db, alias=DEFAULT_CONNECTION_NAME, **kwargs): def connect(db=None, alias=DEFAULT_CONNECTION_NAME, **kwargs):
"""Connect to the database specified by the 'db' argument. """Connect to the database specified by the 'db' argument.
Connection settings may be provided here as well if the database is not Connection settings may be provided here as well if the database is not