Support the current-user-principal property (RFC5397).
authorJelmer Vernooij <jelmer@samba.org>
Sun, 9 Mar 2014 00:10:30 +0000 (00:10 +0000)
committerJelmer Vernooij <jelmer@jelmer.uk>
Sun, 8 Nov 2015 20:32:36 +0000 (20:32 +0000)
calypso/__init__.py
calypso/config.py
calypso/xmlutils.py
config

index 030b6273fefbdeabea0dc44f2f3d7fd5dbb0fb33..06845ac8e94fd606aa4f1974e90fdbe4eb0c564a 100644 (file)
@@ -374,7 +374,8 @@ class CollectionHTTPHandler(server.BaseHTTPRequestHandler):
             log.debug("PROPFIND %s", xml_request)
             self._answer = xmlutils.propfind(
                 self.path, xml_request, self._collection,
-                self.headers.get("depth", "infinity"))
+                self.headers.get("depth", "infinity"),
+                context)
             log.debug("PROPFIND ANSWER %s", self._answer)
 
             self.send_calypso_response(client.MULTI_STATUS, len(self._answer))
index bf28cb92cb0fcf376c104ec8d0dceb731ceaea2d..598d1e2994f691e6040427c3a5959a75dc268d6b 100644 (file)
@@ -46,6 +46,7 @@ INITIAL_CONFIG = {
         "certificate": "/etc/apache2/ssl/server.crt",
         "key": "/etc/apache2/ssl/server.key",
         "pidfile": "/var/run/calypso.pid",
+        "user_principal": "/+%(user)s",
     },
     "encoding": {
         "request": "utf-8",
index 89ed70d97b492a79e8d83282d966cffd5add90a3..aa2584b444c5d1ef62578643995b4c06f67c4e68 100644 (file)
@@ -86,7 +86,7 @@ def delete(path, collection, context):
     return ET.tostring(multistatus, config.get("encoding", "request"))
 
 
-def propfind(path, xml_request, collection, depth):
+def propfind(path, xml_request, collection, depth, context):
     """Read and answer PROPFIND requests.
 
     Read rfc4918-9.1 for info.
@@ -210,6 +210,10 @@ def propfind(path, xml_request, collection, depth):
 #                element.text = time.strftime("%a, %d %b %Y %H:%M:%S +0000", item.last_modified)
 #                element.text = email.utils.formatdate(item.last_modified)
                 element.text = email.utils.formatdate(time.mktime(item.last_modified))
+            elif tag == _tag("D", "current-user-principal"):
+                tag = ET.Element(_tag("D", "href"))
+                tag.text = config.get("server", "user_principal") % context
+                element.append(tag)
             prop.append(element)
 
         status = ET.Element(_tag("D", "status"))
diff --git a/config b/config
index 0c96ddf085788e494202a2033ba4c386d5f0ddae..90c739f2db737411754b9112708a4fe196f19797 100644 (file)
--- a/config
+++ b/config
@@ -20,6 +20,9 @@ certificate = /etc/apache2/ssl/server.crt
 key = /etc/apache2/ssl/server.key
 # File to store the PID of the running calypso instance
 # pidfile = /var/run/calypso.pid
+# current user principal; path to the default collection for a user
+# for clients that use it (RFC5397)
+user_principal = /+%(user)s
 
 [encoding]
 # Encoding for responding requests