Add support for addressbook-description and calendar-description attributes.
authorJelmer Vernooij <jelmer@samba.org>
Sun, 9 Mar 2014 01:12:09 +0000 (01:12 +0000)
committerJelmer Vernooij <jelmer@jelmer.uk>
Thu, 14 Jan 2016 01:37:59 +0000 (01:37 +0000)
See RFC4791, par 5.2.1.

calypso/webdav.py
calypso/xmlutils.py

index b533a5760937d22a4bd1a375113d1132b6d2c741..238067a33f91346b88b75d4523f6a6467aa32739 100644 (file)
@@ -232,6 +232,13 @@ class CalypsoError(Exception):
 class Collection(object):
     """Internal collection class."""
 
+    def get_description(self):
+        f = codecs.open(os.path.join(self.path, ".git/description"), encoding='utf-8')
+        try:
+            return f.read()
+        finally:
+            f.close()
+
     def read_file(self, path):
         text = codecs.open(path,encoding='utf-8').read()
         item = Item(text, None, path)
index 3dfbcff47cf2eaea9a8cd62b22a83573d56fabe6..f9d73d754f2093d91d197696d8bb0ef67d1c8896 100644 (file)
@@ -218,10 +218,9 @@ def propfind(path, xml_request, collection, depth, context):
                 tag = ET.Element(_tag("D", "href"))
                 tag.text = config.get("server", "user_principal") % context
                 element.append(tag)
-            elif tag == _tag("A", "addressbook-description") and is_collection:
-                element.text = collection.read_file(".git/description")
-            elif tag == _tag("C", "calendar-description") and is_collection:
-                element.text = collection.read_file(".git/description")
+            elif tag in (_tag("A", "addressbook-description"),
+                         _tag("C", "calendar-description")) and is_collection:
+                element.text = collection.get_description()
             prop.append(element)
 
         status = ET.Element(_tag("D", "status"))