Report item modification to users in various cases.
This commit is contained in:
parent
f479b4ba67
commit
d4bdc36550
1
NEWS
1
NEWS
@ -17,6 +17,7 @@
|
|||||||
* Twisted dependency removed
|
* Twisted dependency removed
|
||||||
* Python 3 support
|
* Python 3 support
|
||||||
* Real URLs for PUT and DELETE
|
* Real URLs for PUT and DELETE
|
||||||
|
* Concurrent modification reported to users
|
||||||
* Many bugs fixed by Roger Wenham
|
* Many bugs fixed by Roger Wenham
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,15 +188,19 @@ class CalendarHTTPHandler(server.BaseHTTPRequestHandler):
|
|||||||
def do_PUT(self):
|
def do_PUT(self):
|
||||||
"""Manage PUT request."""
|
"""Manage PUT request."""
|
||||||
item = self._calendar.get_item(xmlutils.name_from_path(self.path))
|
item = self._calendar.get_item(xmlutils.name_from_path(self.path))
|
||||||
if not item or self.headers.get("If-Match", item.etag) == item.etag:
|
if (not item and not self.headers.get("If-Match")) or \
|
||||||
# No item, no ETag precondition or precondition verified, put item
|
(item and self.headers.get("If-Match", item.etag) == item.etag):
|
||||||
|
# PUT allowed in 3 cases
|
||||||
|
# Case 1: No item and no ETag precondition: Add new item
|
||||||
|
# Case 2: Item and ETag precondition verified: Modify item
|
||||||
|
# Case 3: Item and no Etag precondition: Force modifying item
|
||||||
ical_request = self._decode(
|
ical_request = self._decode(
|
||||||
self.rfile.read(int(self.headers["Content-Length"])))
|
self.rfile.read(int(self.headers["Content-Length"])))
|
||||||
xmlutils.put(self.path, ical_request, self._calendar)
|
xmlutils.put(self.path, ical_request, self._calendar)
|
||||||
|
|
||||||
self.send_response(client.CREATED)
|
self.send_response(client.CREATED)
|
||||||
else:
|
else:
|
||||||
# ETag precondition not verified, do not put item
|
# PUT rejected in all other cases
|
||||||
self.send_response(client.PRECONDITION_FAILED)
|
self.send_response(client.PRECONDITION_FAILED)
|
||||||
|
|
||||||
@check_rights
|
@check_rights
|
||||||
|
Loading…
Reference in New Issue
Block a user