Added multidb support

No change required to upgrade to multiple databases. Aliases are used
to describe the database and these can be manually registered or fall
through to a default alias using connect.

Made get_connection and get_db first class members of the connection class.
Old style _get_connection and _get_db still supported.

Refs: #84 #87 #93 #215
This commit is contained in:
Ross Lawley
2011-11-18 07:22:37 -08:00
parent 63c5a4dd65
commit e80144e9f2
15 changed files with 180 additions and 103 deletions

View File

@@ -1,4 +1,4 @@
from connection import _get_db
from connection import get_db
from mongoengine import signals
import pprint
@@ -481,7 +481,7 @@ class QuerySet(object):
if self._document not in QuerySet.__already_indexed:
# Ensure collection exists
db = _get_db()
db = get_db()
if self._collection_obj.name not in db.collection_names():
self._document._collection = None
self._collection_obj = self._document._get_collection()
@@ -1436,7 +1436,7 @@ class QuerySet(object):
scope['query'] = query
code = pymongo.code.Code(code, scope=scope)
db = _get_db()
db = get_db()
return db.eval(code, *fields)
def where(self, where_clause):