Skip to content

Commit 3cb181c

Browse files
committed
Merge pull request #131 from buckensl/master
do not ignore 'False' connection settings (fixes #127)
2 parents 90d3d35 + 0942519 commit 3cb181c

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

AUTHORS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ that much better:
2525
* Marcus Carlsson - https://github.com/xintron
2626
* RealJTG - https://github.com/RealJTG
2727
* Peter D. Gray
28-
* Massimo Santini
28+
* Massimo Santini
29+
* Len Buckens - https://github.com/buckensl

flask_mongoengine/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _create_connection(conn_settings):
3131
connections[conn.get('alias')] = _create_connection(conn)
3232
return connections
3333

34-
conn = dict([(k.lower(), v) for k, v in conn_settings.items() if v])
34+
conn = {k.lower(): v for k, v in conn_settings.items() if v is not None}
3535

3636
if 'replicaset' in conn:
3737
conn['replicaSet'] = conn.pop('replicaset')

tests/test_json_app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ def test_connection_kwargs(self):
7474
db.init_app(self.app)
7575
self.assertFalse(db.connection.tz_aware)
7676

77+
def test_connection_kwargs_with_false_values(self):
78+
self.app.config['MONGODB_SETTINGS'] = {
79+
'DB': 'testing',
80+
'alias': 'test',
81+
'use_greenlets': False
82+
}
83+
self.app.config['TESTING'] = True
84+
db = MongoEngine()
85+
db.init_app(self.app)
86+
self.assertFalse(db.connection.use_greenlets)
87+
7788
def test_with_id(self):
7889
c = self.app.test_client()
7990
resp = c.get('/show/38783728378090/')

0 commit comments

Comments
 (0)