Update PROPPATCH to new storage API

This commit is contained in:
Markus Unterwaditzer 2016-04-13 23:02:00 +02:00
parent 472d016d1e
commit e8c1defe6a
2 changed files with 13 additions and 14 deletions

View File

@ -353,7 +353,12 @@ class Collection:
if os.path.exists(props_path): if os.path.exists(props_path):
with open(props_path, encoding=STORAGE_ENCODING) as prop_file: with open(props_path, encoding=STORAGE_ENCODING) as prop_file:
properties.update(json.load(prop_file)) properties.update(json.load(prop_file))
if value:
properties[key] = value properties[key] = value
else:
properties.pop(key, None)
with open(props_path, "w+", encoding=STORAGE_ENCODING) as prop_file: with open(props_path, "w+", encoding=STORAGE_ENCODING) as prop_file:
json.dump(properties, prop_file) json.dump(properties, prop_file)

View File

@ -442,18 +442,12 @@ def proppatch(path, xml_request, collection):
href.text = _href(path) href.text = _href(path)
response.append(href) response.append(href)
with collection.props as collection_props:
for short_name, value in props_to_set.items(): for short_name, value in props_to_set.items():
if short_name.split(":")[-1] == "calendar-timezone": collection.set_meta(short_name, value)
collection.replace(None, value)
collection_props[short_name] = value
_add_propstat_to(response, short_name, 200) _add_propstat_to(response, short_name, 200)
for short_name in props_to_remove: for short_name in props_to_remove:
try: collection.set_meta(short_name, '')
del collection_props[short_name]
except KeyError:
_add_propstat_to(response, short_name, 412)
else:
_add_propstat_to(response, short_name, 200) _add_propstat_to(response, short_name, 200)
return _pretty_xml(multistatus) return _pretty_xml(multistatus)