# Case 2: Item and ETag precondition verified: Modify item
# Case 3: Item and no Etag precondition: Force modifying item
webdav_request = self._decode(self.xml_request)
- xmlutils.put(self.path, webdav_request, self._collection, context=context)
+ new_item = xmlutils.put(self.path, webdav_request, self._collection, context=context)
- new_name = paths.resource_from_path(self.path)
- log.debug("item_name %s new_name %s", item_name, new_name)
- # We need to double get this item, because it just got created
- etag = self._collection.get_item(new_name).etag
+ log.debug("item_name %s new_name %s", item_name, new_item.name)
+ etag = new_item.etag
#log.debug("replacement etag %s", etag)
self.send_calypso_response(client.CREATED, 0)
"""
+ self.log.debug('append name %s', name)
try:
new_item = Item(text, name, None)
except Exception, e:
raise CalypsoError(new_item.name, "Item already present")
self.log.debug("New item %s", new_item.name)
self.create_file(new_item, context=context)
+ return new_item
def remove(self, name, context):
"""Remove object named ``name`` from collection."""
ret = False
if path is not None:
+ self.log.debug('rewrite path %s', path)
self.rewrite_file(new_item, context=context)
else:
+ self.log.debug('remove and append item %s', name)
self.remove(name)
self.append(name, text, context=context)
+ return new_item
def import_item(self, new_item, path):
old_item = self.get_item(new_item.name)
def put(path, webdav_request, collection, context):
"""Read PUT requests."""
name = paths.resource_from_path(path)
+ log.debug('xmlutils put path %s name %s', path, name)
if name in (item.name for item in collection.items):
# PUT is modifying an existing item
- collection.replace(name, webdav_request, context=context)
+ log.debug('Replacing item named %s', name)
+ return collection.replace(name, webdav_request, context=context)
else:
# PUT is adding a new item
log.debug('Putting a new item, because name %s is not known', name)
- collection.append(name, webdav_request, context=context)
+ return collection.append(name, webdav_request, context=context)
def match_filter_element(vobject, fe):