[Calypso] [PATCH] Add server/base_prefix setting.
Jelmer Vernooij
jelmer at samba.org
Sat Mar 8 15:39:54 PST 2014
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 bf28cb9..20c96ef 100644
--- a/calypso/config.py
+++ b/calypso/config.py
@@ -46,6 +46,7 @@ INITIAL_CONFIG = {
"certificate": "/etc/apache2/ssl/server.crt",
"key": "/etc/apache2/ssl/server.key",
"pidfile": "/var/run/calypso.pid",
+ "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 0c96ddf..1c5105e 100644
--- a/config
+++ b/config
@@ -20,6 +20,8 @@ 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
+# base URL if / is not the CalDAV root
+base_prefix = /
[encoding]
# Encoding for responding requests
--
1.9.0.279.gdc9e3eb
More information about the Calypso
mailing list