def delete(self, href, etag): try: entry = self._journal.collection.get(href) old_item = Item(entry.content) if old_item.hash != etag: raise exceptions.WrongEtagError(etag, old_item.hash) entry.delete() except etesync.exceptions.DoesNotExist as e: raise exceptions.NotFoundError(e)
def upload(self, item): try: entry = self._item_type.create(self._journal.collection, item.raw) entry.save() except etesync.exceptions.DoesNotExist as e: raise exceptions.NotFoundError(e) except etesync.exceptions.AlreadyExists as e: raise exceptions.AlreadyExistingError(e) return item.uid, item.hash
def update(self, href, item, etag): try: entry = self._journal.collection.get(href) except etesync.exceptions.DoesNotExist as e: raise exceptions.NotFoundError(e) old_item = Item(entry.content) if old_item.hash != etag: raise exceptions.WrongEtagError(etag, old_item.hash) entry.content = item.raw entry.save() return item.hash
def get(self, href): try: item = Item(self._journal.collection.get(href).content) except etesync.exceptions.DoesNotExist as e: raise exceptions.NotFoundError(e) return item, item.hash