cgi.py: Set the default static URL prefix from user's `SCRIPT_NAME'.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 22 Dec 2014 20:32:58 +0000 (20:32 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 7 Apr 2015 18:54:17 +0000 (19:54 +0100)
Otherwise you have to set them both, and that's just annoying.

cgi.py

diff --git a/cgi.py b/cgi.py
index 8009eaf..6ad9e75 100644 (file)
--- a/cgi.py
+++ b/cgi.py
@@ -51,7 +51,11 @@ CONF.DEFAULTS.update(
 
   ## A (maybe relative) URL for static content.  By default this comes from
   ## the main script, but we hope that user agents cache it.
-  STATIC = _script_name + '/static')
+  STATIC = None)
+
+@CONF.hook
+def set_static():
+  if CFG.STATIC is None: CFG.STATIC = CFG.SCRIPT_NAME + '/static'
 
 ###--------------------------------------------------------------------------
 ### Escaping and encoding.