Fix ssl param default value

This commit is contained in:
Thomas Conte 2017-03-27 10:43:40 +02:00
parent 550b9cb804
commit 58d80e9731
2 changed files with 4 additions and 6 deletions

View File

@ -16,7 +16,7 @@ logger = logging.getLogger(__name__)
def connect(backend=None, host=None, port=None, name=None, max_tries=None, def connect(backend=None, host=None, port=None, name=None, max_tries=None,
connection_timeout=None, replicaset=None, ssl=False, login=None, password=None): connection_timeout=None, replicaset=None, ssl=None, login=None, password=None):
"""Create a new connection to the database backend. """Create a new connection to the database backend.
All arguments default to the current configuration's values if not All arguments default to the current configuration's values if not
@ -50,8 +50,7 @@ def connect(backend=None, host=None, port=None, name=None, max_tries=None,
# to handle these these additional args. In case of RethinkDBConnection # to handle these these additional args. In case of RethinkDBConnection
# it just does not do anything with it. # it just does not do anything with it.
replicaset = replicaset or bigchaindb.config['database'].get('replicaset') replicaset = replicaset or bigchaindb.config['database'].get('replicaset')
ssl = bigchaindb.config['database'].get('ssl') if bigchaindb.config['database'].get('ssl') is not None \ ssl = ssl if ssl is not None else bigchaindb.config['database'].get('ssl', False)
else ssl
login = login or bigchaindb.config['database'].get('login') login = login or bigchaindb.config['database'].get('login')
password = password or bigchaindb.config['database'].get('password') password = password or bigchaindb.config['database'].get('password')

View File

@ -16,7 +16,7 @@ logger = logging.getLogger(__name__)
class MongoDBConnection(Connection): class MongoDBConnection(Connection):
def __init__(self, replicaset=None, ssl=False, login=None, password=None, **kwargs): def __init__(self, replicaset=None, ssl=None, login=None, password=None, **kwargs):
"""Create a new Connection instance. """Create a new Connection instance.
Args: Args:
@ -28,8 +28,7 @@ class MongoDBConnection(Connection):
super().__init__(**kwargs) super().__init__(**kwargs)
self.replicaset = replicaset or bigchaindb.config['database']['replicaset'] self.replicaset = replicaset or bigchaindb.config['database']['replicaset']
self.ssl = bigchaindb.config['database'].get('ssl') if bigchaindb.config['database'].get('ssl') is not None \ self.ssl = ssl if ssl is not None else bigchaindb.config['database'].get('ssl', False)
else ssl
self.login = login or bigchaindb.config['database'].get('login') self.login = login or bigchaindb.config['database'].get('login')
self.password = password or bigchaindb.config['database'].get('password') self.password = password or bigchaindb.config['database'].get('password')