[Calypso] [PATCH 01/35] Add server/base_prefix setting.
Jelmer Vernooij
jelmer at jelmer.uk
Sat Jan 9 10:56:25 PST 2016
From: Jelmer Vernooij <jelmer at debian.org>
---
calypso/config.py | 1 +
calypso/paths.py | 11 +++++++++++
config | 2 ++
3 files changed, 14 insertions(+)
diff --git a/calypso/config.py b/calypso/config.py
index 598d1e2..dc17eec 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",
"user_principal": "/+%(user)s",
+ "base_prefix": "/",
},
"encoding": {
"request": "utf-8",
diff --git a/calypso/paths.py b/calypso/paths.py
index 11640aa..d69b667 100644
--- a/calypso/paths.py
+++ b/calypso/paths.py
@@ -45,6 +45,14 @@ def url_to_owner(path):
def data_root():
return os.path.expanduser(config.get("storage", "folder"))
+
+#
+# Return the base path for the web server.
+#
+
+def base_prefix():
+ return config.get("server", "base_prefix").rstrip("/")
+
#
# Given a URL, convert it to an absolute path name by
# prepending the storage folder name
@@ -53,12 +61,15 @@ def data_root():
#
def url_to_file(url):
+ if url.startswith(base_prefix()):
+ url = "/" + url[len(base_prefix()):].lstrip("/")
tail = urllib.url2pathname(url.strip("/"))
# eliminate .. components, and potential double leading slashes
tail = posixpath.normpath('/' + tail).lstrip('/')
file = os.path.join(data_root(), tail)
return file
+
#
# Does the provided URL reference a collection? This
# is done by seeing if the resulting path is a directory
diff --git a/config b/config
index 90c739f..1ef574c 100644
--- a/config
+++ b/config
@@ -23,6 +23,8 @@ key = /etc/apache2/ssl/server.key
# current user principal; path to the default collection for a user
# for clients that use it (RFC5397)
user_principal = /+%(user)s
+# base URL if / is not the CalDAV root
+base_prefix = /
[encoding]
# Encoding for responding requests
--
2.7.0.rc3
More information about the Calypso
mailing list