[Calypso] [PATCH] Support the current-user-principal property (RFC5397).
Guido Günther
agx at sigxcpu.org
Sun Nov 8 07:32:46 PST 2015
Hi,
On Sun, Nov 08, 2015 at 01:43:10PM +0000, Jelmer Vernooij wrote:
> From: Jelmer Vernooij <jelmer at jelmer.uk>
>
> ---
> calypso/__init__.py | 3 ++-
> calypso/config.py | 1 +
> calypso/xmlutils.py | 6 +++++-
> config | 3 +++
> 4 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/calypso/__init__.py b/calypso/__init__.py
> index ba53288..36349b9 100644
> --- a/calypso/__init__.py
> +++ b/calypso/__init__.py
> @@ -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))
> diff --git a/calypso/config.py b/calypso/config.py
> index 20c96ef..67645be 100644
> --- a/calypso/config.py
> +++ b/calypso/config.py
> @@ -47,6 +47,7 @@ INITIAL_CONFIG = {
> "key": "/etc/apache2/ssl/server.key",
> "pidfile": "/var/run/calypso.pid",
> "base_prefix": "/",
> + "user_principal": "/+%(user)s",
> },
> "encoding": {
> "request": "utf-8",
> diff --git a/calypso/xmlutils.py b/calypso/xmlutils.py
> index a1e8c8c..d873edf 100644
> --- a/calypso/xmlutils.py
> +++ b/calypso/xmlutils.py
> @@ -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 = paths.base_prefix() + 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 1c5105e..a326cbf 100644
> --- a/config
> +++ b/config
> @@ -22,6 +22,9 @@ key = /etc/apache2/ssl/server.key
> # pidfile = /var/run/calypso.pid
> # base URL if / is not the CalDAV root
> base_prefix = /
> +# 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
This looks good to me. You should have commit rights to the repo already.
Cheers,
-- Guido
More information about the Calypso
mailing list