Explorar el Código

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

Guillaume Ayoub hace 14 años
padre
commit
b5e94598e9
Se han modificado 1 ficheros con 7 adiciones y 1 borrados
  1. 7 1
      radicale/__init__.py

+ 7 - 1
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