Exemplo n.º 1
0
 def save(self):
     created = not self.pk
     pre_save.send(sender=type(self), instance=self)
     backend = self._meta.get_backend()
     data = type(self).to_primitive(self)
     backend.save(type(self), self._meta.collection, data)
     post_save.send(sender=type(self), instance=self, created=created)
Exemplo n.º 2
0
 def save(self):
     from dockit.backends import get_index_router
     created = not self.pk
     pre_save.send(sender=type(self), instance=self)
     backend = self._meta.get_document_backend_for_write()
     data = type(self).to_primitive(self)
     backend.save(type(self), self._meta.collection, data)
     get_index_router().on_save(type(self), self._meta.collection, self.get_id(), data)
     post_save.send(sender=type(self), instance=self, created=created)