Add etag property to items

Related to #380.
This commit is contained in:
Guillaume Ayoub 2016-04-20 07:49:03 +09:00
parent bf8bd90bcb
commit 3a9bcc7555
2 changed files with 5 additions and 1 deletions

View File

@ -127,6 +127,10 @@ class Item:
def content_length(self): def content_length(self):
return len(self.serialize().encode(config.get("encoding", "request"))) return len(self.serialize().encode(config.get("encoding", "request")))
@property
def etag(self):
return get_etag(self.serialize())
class Collection: class Collection:
"""Collection stored in several files per calendar.""" """Collection stored in several files per calendar."""

View File

@ -271,7 +271,7 @@ def _propfind_response(path, item, props, user, write=False):
element = ET.Element(tag) element = ET.Element(tag)
is404 = False is404 = False
if tag == _tag("D", "getetag"): if tag == _tag("D", "getetag"):
element.text = storage.get_etag(item.serialize()) element.text = item.etag
elif tag == _tag("D", "principal-URL"): elif tag == _tag("D", "principal-URL"):
tag = ET.Element(_tag("D", "href")) tag = ET.Element(_tag("D", "href"))
tag.text = _href(path) tag.text = _href(path)