Created
August 16, 2011 14:05
-
-
Save rozza/1149167 to your computer and use it in GitHub Desktop.
Extended EmbeddedDocumentField for MongoEngine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExtendedEmbeddedDocumentField(BaseField): | |
"""An embedded document field attaches the owner_document to field, | |
when pulled from the database. | |
""" | |
def to_python(self, value): | |
if not isinstance(value, self.document_type): | |
embedded = self.document_type._from_son(value) | |
embedded._owner_document = self.owner_document | |
return embedded | |
return value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment