fixes for rebase branch
This commit is contained in:
		| @@ -268,7 +268,6 @@ class BaseDocument(object): | |||||||
|         data["_id"] = None |         data["_id"] = None | ||||||
|         data['_cls'] = self._class_name |         data['_cls'] = self._class_name | ||||||
|         EmbeddedDocumentField = _import_class("EmbeddedDocumentField") |         EmbeddedDocumentField = _import_class("EmbeddedDocumentField") | ||||||
|  |  | ||||||
|         # only root fields ['test1.a', 'test2'] => ['test1', 'test2'] |         # only root fields ['test1.a', 'test2'] => ['test1', 'test2'] | ||||||
|         root_fields = set([f.split('.')[0] for f in fields]) |         root_fields = set([f.split('.')[0] for f in fields]) | ||||||
|  |  | ||||||
| @@ -283,20 +282,20 @@ class BaseDocument(object): | |||||||
|                 field = self._dynamic_fields.get(field_name) |                 field = self._dynamic_fields.get(field_name) | ||||||
|  |  | ||||||
|             if value is not None: |             if value is not None: | ||||||
|                 EmbeddedDocument = _import_class("EmbeddedDocument") |  | ||||||
|                 if isinstance(value, (EmbeddedDocument)) and \ |  | ||||||
|                         not use_db_field: |  | ||||||
|                     value = field.to_mongo(value, use_db_field) |  | ||||||
|                 else: |  | ||||||
|                     value = field.to_mongo(value) |  | ||||||
|  |  | ||||||
|             if isinstance(field, EmbeddedDocumentField) and fields: |                 if isinstance(field, (EmbeddedDocumentField)): | ||||||
|  |                     if fields: | ||||||
|                         key = '%s.' % field_name |                         key = '%s.' % field_name | ||||||
|  |                         embedded_fields = [ | ||||||
|  |                             i.replace(key, '') for i in fields | ||||||
|  |                             if i.startswith(key)] | ||||||
|  |  | ||||||
|                 value = field.to_mongo(value, fields=[ |                     else: | ||||||
|                     i.replace(key, '') for i in fields if i.startswith(key)]) |                         embedded_fields = [] | ||||||
|  |  | ||||||
|             elif value is not None: |                     value = field.to_mongo(value, use_db_field=use_db_field, | ||||||
|  |                                            fields=embedded_fields) | ||||||
|  |                 else: | ||||||
|                     value = field.to_mongo(value) |                     value = field.to_mongo(value) | ||||||
|  |  | ||||||
|             # Handle self generating fields |             # Handle self generating fields | ||||||
|   | |||||||
| @@ -570,7 +570,8 @@ class EmbeddedDocumentField(BaseField): | |||||||
|     def to_mongo(self, value, use_db_field=True, fields=[]): |     def to_mongo(self, value, use_db_field=True, fields=[]): | ||||||
|         if not isinstance(value, self.document_type): |         if not isinstance(value, self.document_type): | ||||||
|             return value |             return value | ||||||
|         return self.document_type.to_mongo(value, use_db_field) |         return self.document_type.to_mongo(value, use_db_field, | ||||||
|  |                                            fields=fields) | ||||||
|  |  | ||||||
|     def validate(self, value, clean=True): |     def validate(self, value, clean=True): | ||||||
|         """Make sure that the document instance is an instance of the |         """Make sure that the document instance is an instance of the | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user