Fix for inheritance bug and db_alias

This commit is contained in:
Ross Lawley
2012-07-20 10:34:08 +01:00
parent 83c11a9834
commit 3070e0bf5d
5 changed files with 29 additions and 11 deletions

View File

@@ -12,7 +12,7 @@ from signals import *
__all__ = (document.__all__ + fields.__all__ + connection.__all__ +
queryset.__all__ + signals.__all__)
VERSION = (0, 6, 15)
VERSION = (0, 6, 16)
def get_version():

View File

@@ -649,8 +649,13 @@ class TopLevelDocumentMetaclass(DocumentMetaclass):
del(attrs['meta']['collection'])
if base._get_collection_name():
collection = base._get_collection_name()
# Propagate index options.
for key in ('index_background', 'index_drop_dups', 'index_opts'):
# Propagate inherited values
keys_to_propogate = (
'index_background', 'index_drop_dups', 'index_opts',
'allow_inheritance', 'queryset_class', 'db_alias',
)
for key in keys_to_propogate:
if key in base._meta:
base_meta[key] = base._meta[key]
@@ -659,11 +664,6 @@ class TopLevelDocumentMetaclass(DocumentMetaclass):
abstract_base_indexes += base._meta.get('indexes', [])
else:
base_indexes += base._meta.get('indexes', [])
# Propagate 'allow_inheritance'
if 'allow_inheritance' in base._meta:
base_meta['allow_inheritance'] = base._meta['allow_inheritance']
if 'queryset_class' in base._meta:
base_meta['queryset_class'] = base._meta['queryset_class']
try:
base_meta['objects'] = base.__getattribute__(base, 'objects')
except TypeError:
@@ -671,6 +671,7 @@ class TopLevelDocumentMetaclass(DocumentMetaclass):
except AttributeError:
pass
# defaults
meta = {
'abstract': False,
'collection': collection,