@@ -44,19 +44,30 @@ def init_app(self, app):
4444 'port' : int (app .config .get ('MONGODB_PORT' , 0 )) or None
4545 }
4646
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 ])
4851
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' ]
5255
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 )
5466
5567 app .extensions = getattr (app , 'extensions' , {})
5668 app .extensions ['mongoengine' ] = self
5769 self .app = app
5870
59-
6071class BaseQuerySet (QuerySet ):
6172 """
6273 A base queryset with handy extras
0 commit comments