Beispiel #1
0
 def create_from_instance(cls, instance):
     backend = get_document_backend()
     data = instance.to_primitive(instance)
     instance_id = data.pop(backend.get_id_field_name(), None)
     obj = cls.to_python(data)
     obj._original_id = instance_id
     return obj
Beispiel #2
0
 def create_from_instance(cls, instance):
     backend = get_document_backend()
     data = instance.to_primitive(instance)
     instance_id = data.pop(backend.get_id_field_name(), None)
     obj = cls.to_python(data)
     obj._original_id = instance_id
     return obj
Beispiel #3
0
 def commit_changes(self, doc_id=None):
     document_cls = self._meta.original_document
     
     backend = get_document_backend()
     id_field = backend.get_id_field_name()
     
     data = self.to_primitive(self)
     data[id_field] = doc_id
     data.pop('_tempinfo', None)
     
     instance = document_cls(_primitive_data=data)
     instance.save()
     return instance
Beispiel #4
0
 def commit_changes(self, doc_id=None):
     document_cls = self._meta.original_document
     
     backend = get_document_backend()
     id_field = backend.get_id_field_name()
     
     data = self.to_primitive(self)
     data[id_field] = doc_id
     data.pop('_tempinfo', None)
     
     instance = document_cls(_primitive_data=data)
     instance.save()
     return instance
Beispiel #5
0
 def get_backend(self):
     return get_document_backend(self._document)