Fixed upgrade docs and instructions
This commit is contained in:
		| @@ -76,7 +76,7 @@ To upgrade use a Mixin class to set meta like so :: | |||||||
|     class MyAceDocument(Document, BaseMixin): |     class MyAceDocument(Document, BaseMixin): | ||||||
|         pass |         pass | ||||||
|  |  | ||||||
|     MyAceDocument._get_collection_name() == myacedocument |     MyAceDocument._get_collection_name() == "myacedocument" | ||||||
|  |  | ||||||
| Alternatively, you can rename your collections eg :: | Alternatively, you can rename your collections eg :: | ||||||
|  |  | ||||||
|   | |||||||
| @@ -478,13 +478,18 @@ class DocumentMetaclass(type): | |||||||
|             attrs.update(dict([(k, v) for k, v in base.__dict__.items() |             attrs.update(dict([(k, v) for k, v in base.__dict__.items() | ||||||
|                                if issubclass(v.__class__, BaseField)])) |                                if issubclass(v.__class__, BaseField)])) | ||||||
|  |  | ||||||
|  |             # Handle simple mixin's with meta | ||||||
|  |             if hasattr(base, 'meta') and not isinstance(base, DocumentMetaclass): | ||||||
|  |                 meta = attrs.get('meta', {}) | ||||||
|  |                 meta.update(base.meta) | ||||||
|  |                 attrs['meta'] = meta | ||||||
|  |  | ||||||
|             for p_base in base.__bases__: |             for p_base in base.__bases__: | ||||||
|                 #optimize :-) |                 #optimize :-) | ||||||
|                 if p_base in (object, BaseDocument): |                 if p_base in (object, BaseDocument): | ||||||
|                     continue |                     continue | ||||||
|  |  | ||||||
|                 attrs.update(_get_mixin_fields(p_base)) |                 attrs.update(_get_mixin_fields(p_base)) | ||||||
|  |  | ||||||
|             return attrs |             return attrs | ||||||
|  |  | ||||||
|         metaclass = attrs.get('__metaclass__') |         metaclass = attrs.get('__metaclass__') | ||||||
| @@ -498,6 +503,7 @@ class DocumentMetaclass(type): | |||||||
|         simple_class = True |         simple_class = True | ||||||
|  |  | ||||||
|         for base in bases: |         for base in bases: | ||||||
|  |  | ||||||
|             # Include all fields present in superclasses |             # Include all fields present in superclasses | ||||||
|             if hasattr(base, '_fields'): |             if hasattr(base, '_fields'): | ||||||
|                 doc_fields.update(base._fields) |                 doc_fields.update(base._fields) | ||||||
| @@ -526,7 +532,8 @@ class DocumentMetaclass(type): | |||||||
|                     simple_class = False |                     simple_class = False | ||||||
|  |  | ||||||
|         doc_class_name = '.'.join(reversed(class_name)) |         doc_class_name = '.'.join(reversed(class_name)) | ||||||
|         meta = attrs.get('_meta', attrs.get('meta', {})) |         meta = attrs.get('_meta', {}) | ||||||
|  |         meta.update(attrs.get('meta', {})) | ||||||
|  |  | ||||||
|         if 'allow_inheritance' not in meta: |         if 'allow_inheritance' not in meta: | ||||||
|             meta['allow_inheritance'] = True |             meta['allow_inheritance'] = True | ||||||
|   | |||||||
| @@ -96,7 +96,7 @@ class DocumentTest(unittest.TestCase): | |||||||
|         # Ensure Document isn't treated like an actual document |         # Ensure Document isn't treated like an actual document | ||||||
|         self.assertFalse(hasattr(Document, '_fields')) |         self.assertFalse(hasattr(Document, '_fields')) | ||||||
|  |  | ||||||
|     def test_collection_name(self): |     def test_collection_naming(self): | ||||||
|         """Ensure that a collection with a specified name may be used. |         """Ensure that a collection with a specified name may be used. | ||||||
|         """ |         """ | ||||||
|  |  | ||||||
| @@ -157,11 +157,12 @@ class DocumentTest(unittest.TestCase): | |||||||
|             } |             } | ||||||
|  |  | ||||||
|         class BaseDocument(Document, BaseMixin): |         class BaseDocument(Document, BaseMixin): | ||||||
|             pass |             meta = {'allow_inheritance': True} | ||||||
|  |  | ||||||
|         class MyDocument(BaseDocument): |         class MyDocument(BaseDocument): | ||||||
|             pass |             pass | ||||||
|         self.assertEquals('mydocument', OldMixinNamingConvention._get_collection_name()) |  | ||||||
|  |         self.assertEquals('basedocument', MyDocument._get_collection_name()) | ||||||
|  |  | ||||||
|     def test_get_superclasses(self): |     def test_get_superclasses(self): | ||||||
|         """Ensure that the correct list of superclasses is assembled. |         """Ensure that the correct list of superclasses is assembled. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user