Allow creation of empty collection via PUT
This commit is contained in:
parent
28e643dec1
commit
4861b79878
@ -547,20 +547,25 @@ class Application:
|
|||||||
# Case 2: Item and ETag precondition verified: Modify item
|
# Case 2: Item and ETag precondition verified: Modify item
|
||||||
# Case 3: Item and no Etag precondition: Force modifying item
|
# Case 3: Item and no Etag precondition: Force modifying item
|
||||||
items = list(vobject.readComponents(content or ""))
|
items = list(vobject.readComponents(content or ""))
|
||||||
if items:
|
if item:
|
||||||
if item:
|
# PUT is modifying an existing item
|
||||||
# PUT is modifying an existing item
|
if items:
|
||||||
new_item = collection.update(item_name, items[0])
|
new_item = collection.update(item_name, items[0])
|
||||||
elif item_name:
|
else:
|
||||||
# PUT is adding a new item
|
new_item = None
|
||||||
|
elif item_name:
|
||||||
|
# PUT is adding a new item
|
||||||
|
if items:
|
||||||
new_item = collection.upload(item_name, items[0])
|
new_item = collection.upload(item_name, items[0])
|
||||||
else:
|
else:
|
||||||
# PUT is replacing the whole collection
|
new_item = None
|
||||||
collection.delete()
|
else:
|
||||||
new_item = self.Collection.create_collection(
|
# PUT is replacing the whole collection
|
||||||
environ["PATH_INFO"], items)
|
collection.delete()
|
||||||
if new_item:
|
new_item = self.Collection.create_collection(
|
||||||
headers["ETag"] = new_item.etag
|
environ["PATH_INFO"], items)
|
||||||
|
if new_item:
|
||||||
|
headers["ETag"] = new_item.etag
|
||||||
status = client.CREATED
|
status = client.CREATED
|
||||||
else:
|
else:
|
||||||
# PUT rejected in all other cases
|
# PUT rejected in all other cases
|
||||||
|
Loading…
Reference in New Issue
Block a user