Skip to content

Instantly share code, notes, and snippets.

@gone
Created November 3, 2011 22:43
Show Gist options
  • Save gone/1338143 to your computer and use it in GitHub Desktop.
Save gone/1338143 to your computer and use it in GitHub Desktop.
def __set__(self, instance, value):
"""Descriptor for assigning a value to a field in a document.
"""
if isinstance(self.field, EmbeddedDocumentField) and:
list_of_docs = list()
for doc in value:
if isinstance(doc, dict):
doc_obj = self.field.document_type_obj(**doc)
doc = doc_obj
list_of_docs.append(doc)
value = list_of_docs
instance._data[self.field_name] = value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment