Fixed inheritance collection issue

This commit is contained in:
Harry Marr
2010-10-17 17:41:20 +01:00
parent dcec61e9b2
commit e93c4c87d8
2 changed files with 38 additions and 8 deletions

View File

@@ -1146,9 +1146,8 @@ class QuerySetManager(object):
return self
db = _get_db()
if db not in self._collections:
collection = owner._meta['collection']
collection = owner._meta['collection']
if (db, collection) not in self._collections:
# Create collection as a capped collection if specified
if owner._meta['max_size'] or owner._meta['max_documents']:
# Get max document limit and max byte size from meta
@@ -1156,10 +1155,10 @@ class QuerySetManager(object):
max_documents = owner._meta['max_documents']
if collection in db.collection_names():
self._collections[db] = db[collection]
self._collections[(db, collection)] = db[collection]
# The collection already exists, check if its capped
# options match the specified capped options
options = self._collections[db].options()
options = self._collections[(db, collection)].options()
if options.get('max') != max_documents or \
options.get('size') != max_size:
msg = ('Cannot create collection "%s" as a capped '
@@ -1170,15 +1169,15 @@ class QuerySetManager(object):
opts = {'capped': True, 'size': max_size}
if max_documents:
opts['max'] = max_documents
self._collections[db] = db.create_collection(
self._collections[(db, collection)] = db.create_collection(
collection, **opts
)
else:
self._collections[db] = db[collection]
self._collections[(db, collection)] = db[collection]
# owner is the document that contains the QuerySetManager
queryset_class = owner._meta['queryset_class'] or QuerySet
queryset = queryset_class(owner, self._collections[db])
queryset = queryset_class(owner, self._collections[(db, collection)])
if self._manager_func:
if self._manager_func.func_code.co_argcount == 1:
queryset = self._manager_func(queryset)