From 3a9bcc7555a48c8bbc624e469c1cdaf89f84abca Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Wed, 20 Apr 2016 07:49:03 +0900 Subject: [PATCH] Add etag property to items Related to #380. --- radicale/storage.py | 4 ++++ radicale/xmlutils.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/radicale/storage.py b/radicale/storage.py index 81ba592..2f830ff 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -127,6 +127,10 @@ class Item: def content_length(self): return len(self.serialize().encode(config.get("encoding", "request"))) + @property + def etag(self): + return get_etag(self.serialize()) + class Collection: """Collection stored in several files per calendar.""" diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index 12d21e1..21794ee 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -271,7 +271,7 @@ def _propfind_response(path, item, props, user, write=False): element = ET.Element(tag) is404 = False if tag == _tag("D", "getetag"): - element.text = storage.get_etag(item.serialize()) + element.text = item.etag elif tag == _tag("D", "principal-URL"): tag = ET.Element(_tag("D", "href")) tag.text = _href(path)