From b5e94598e91d7fdbe6abd9944d336b4ffd099551 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 27 Apr 2012 16:03:14 +0200 Subject: [PATCH] No etag returned when an added item doesn't have the same name as the one given by the client (closes #799) --- radicale/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 73996b2c..8abf1307 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -441,7 +441,13 @@ class Application(object): # Case 3: Item and no Etag precondition: Force modifying item xmlutils.put(environ["PATH_INFO"], content, collection) 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: # PUT rejected in all other cases status = client.PRECONDITION_FAILED