Merge pull request #790 from DavidBord/fix-789

fix-#789: abstract shouldn't be inherited in EmbeddedDocument
This commit is contained in:
DavidBord 2014-10-29 13:39:56 +02:00
commit 8ac3e725f8
3 changed files with 13 additions and 1 deletions

View File

@ -5,6 +5,7 @@ Changelog
Changes in 0.9.X - DEV
======================
- abstract shouldn't be inherited in EmbeddedDocument # 789
- Allow specifying the '_cls' as a field for indexes #397
- Stop ensure_indexes running on a secondaries unless connection is through mongos #746
- Not overriding default values when loading a subset of fields #399

View File

@ -46,8 +46,9 @@ class DocumentMetaclass(type):
elif hasattr(base, '_meta'):
meta.merge(base._meta)
attrs['_meta'] = meta
attrs['_meta']['abstract'] = False # 789: EmbeddedDocument shouldn't inherit abstract
if '_meta' in attrs and attrs['_meta'].get('allow_inheritance', ALLOW_INHERITANCE):
if attrs['_meta'].get('allow_inheritance', ALLOW_INHERITANCE):
StringField = _import_class('StringField')
attrs['_cls'] = StringField()

View File

@ -397,6 +397,16 @@ class InheritanceTest(unittest.TestCase):
meta = {'abstract': True}
self.assertRaises(ValueError, create_bad_abstract)
def test_abstract_embedded_documents(self):
# 789: EmbeddedDocument shouldn't inherit abstract
class A(EmbeddedDocument):
meta = {"abstract": True}
class B(A):
pass
self.assertFalse(B._meta["abstract"])
def test_inherited_collections(self):
"""Ensure that subclassed documents don't override parents'
collections