Fix a bug with DELETE requests when deleted item is not found

This commit is contained in:
Guillaume Ayoub 2012-03-21 11:26:06 +01:00
parent 085c9f0aca
commit f6ace2b6ec

View File

@ -285,17 +285,16 @@ class Application(object):
item = collection.get_item( item = collection.get_item(
xmlutils.name_from_path(environ["PATH_INFO"], collection)) xmlutils.name_from_path(environ["PATH_INFO"], collection))
if item:
# Evolution bug workaround # Evolution bug workaround
etag = environ.get("HTTP_IF_MATCH", item.etag).replace("\\", "") etag = environ.get("HTTP_IF_MATCH", item.etag).replace("\\", "")
if item and etag == item.etag: if etag == item.etag:
# No ETag precondition or precondition verified, delete item # No ETag precondition or precondition verified, delete item
answer = xmlutils.delete(environ["PATH_INFO"], collection) answer = xmlutils.delete(environ["PATH_INFO"], collection)
status = client.NO_CONTENT return client.NO_CONTENT, {}, answer
else:
# No item or ETag precondition not verified, do not delete item # No item or ETag precondition not verified, do not delete item
answer = None return client.PRECONDITION_FAILED, {}, None
status = client.PRECONDITION_FAILED
return status, {}, answer
def get(self, environ, collections, content, user): def get(self, environ, collections, content, user):
"""Manage GET request. """Manage GET request.