@@ -44,19 +44,30 @@ def init_app(self, app):
44
44
'port' : int (app .config .get ('MONGODB_PORT' , 0 )) or None
45
45
}
46
46
47
- conn_settings = dict ([(k .lower (), v ) for k , v in conn_settings .items () if v ])
47
+ if isinstance (conn_settings , list ):
48
+ self .connection = {}
49
+ for conn in conn_settings :
50
+ conn = dict ([(k .lower (), v ) for k , v in conn .items () if v ])
48
51
49
- if 'replicaset' in conn_settings :
50
- conn_settings ['replicaSet' ] = conn_settings ['replicaset' ]
51
- del conn_settings ['replicaset' ]
52
+ if 'replicaset' in conn :
53
+ conn ['replicaSet' ] = conn ['replicaset' ]
54
+ del conn ['replicaset' ]
52
55
53
- self .connection = mongoengine .connect (** conn_settings )
56
+ self .connection [conn .get ('alias' )] = mongoengine .connect (** conn )
57
+
58
+ else :
59
+ conn_settings = dict ([(k .lower (), v ) for k , v in conn_settings .items () if v ])
60
+
61
+ if 'replicaset' in conn_settings :
62
+ conn_settings ['replicaSet' ] = conn_settings ['replicaset' ]
63
+ del conn_settings ['replicaset' ]
64
+
65
+ self .connection = mongoengine .connect (** conn_settings )
54
66
55
67
app .extensions = getattr (app , 'extensions' , {})
56
68
app .extensions ['mongoengine' ] = self
57
69
self .app = app
58
70
59
-
60
71
class BaseQuerySet (QuerySet ):
61
72
"""
62
73
A base queryset with handy extras
0 commit comments