@@ -31,15 +31,18 @@ def __init__(self, app=None):
31
31
32
32
def init_app (self , app ):
33
33
34
- conn_settings = {
35
- 'db' : app .config .get ('MONGODB_DB' , None ),
36
- 'username' : app .config .get ('MONGODB_USERNAME' , None ),
37
- 'password' : app .config .get ('MONGODB_PASSWORD' , None ),
38
- 'host' : app .config .get ('MONGODB_HOST' , None ),
39
- 'port' : int (app .config .get ('MONGODB_PORT' , 0 )) or None
40
- }
41
-
42
- conn_settings = dict ([(k , v ) for k , v in conn_settings .items () if v ])
34
+ conn_settings = app .config .get ('MONGODB_SETTINGS' , None )
35
+
36
+ if not conn_settings :
37
+ conn_settings = {
38
+ 'db' : app .config .get ('MONGODB_DB' , None ),
39
+ 'username' : app .config .get ('MONGODB_USERNAME' , None ),
40
+ 'password' : app .config .get ('MONGODB_PASSWORD' , None ),
41
+ 'host' : app .config .get ('MONGODB_HOST' , None ),
42
+ 'port' : int (app .config .get ('MONGODB_PORT' , 0 )) or None
43
+ }
44
+
45
+ conn_settings = dict ([(k .lower (), v ) for k , v in conn_settings .items () if v ])
43
46
44
47
self .connection = mongoengine .connect (** conn_settings )
45
48
0 commit comments