No etag returned when an added item doesn't have the same name as the one given by the client (closes #799)

This commit is contained in:
Guillaume Ayoub 2012-04-27 16:03:14 +02:00
parent ca5c0483b0
commit b5e94598e9

View File

@ -441,7 +441,13 @@ class Application(object):
# Case 3: Item and no Etag precondition: Force modifying item # Case 3: Item and no Etag precondition: Force modifying item
xmlutils.put(environ["PATH_INFO"], content, collection) xmlutils.put(environ["PATH_INFO"], content, collection)
status = client.CREATED status = client.CREATED
headers["ETag"] = collection.get_item(item_name).etag # Try to return the etag in the header
# If the added item does't have the same name as the one given by
# the client, then there's no obvious way to generate an etag, we
# can safely ignore it.
new_item = collection.get_item(item_name)
if new_item:
headers["ETag"] = new_item.etag
else: else:
# PUT rejected in all other cases # PUT rejected in all other cases
status = client.PRECONDITION_FAILED status = client.PRECONDITION_FAILED