def create_document_dictionary(self, document, document_key=None,<EOL>owner_document=None):
doc_dict = self.create_doc_dict(document, document_key, owner_document)<EOL>for doc_key, doc_field in doc_dict.items():<EOL><INDENT>if doc_key.startswith("<STR_LIT:_>"):<EOL><INDENT>continue<EOL><DEDENT>if isinstance(doc_field, ListField):<EOL><INDENT>doc_dict[doc_key] = self.create_list_dict(document, doc_field, doc_key)<EOL><DEDENT>elif isinstance(doc_field, EmbeddedDocumentField):<EOL><INDENT>doc_dict[doc_key] = self.create_document_dictionary(doc_dict[doc_key].document_type_obj,<EOL>doc_key)<EOL><DEDENT>else:<EOL><INDENT>doc_dict[doc_key] = {"<STR_LIT>": document,<EOL>"<STR_LIT>": doc_key,<EOL>"<STR_LIT>": doc_field,<EOL>"<STR_LIT>": get_widget(doc_dict[doc_key], getattr(doc_field, '<STR_LIT>', False))}<EOL><DEDENT><DEDENT>return doc_dict<EOL>
Given document generates a dictionary representation of the document.
Includes the widget for each for each field in the document.