python: Absolutify WSGI SCRIPT_FILENAME path.
[ashd.git] / python / ashd-wsgi
index beb39ca..422fc9f 100755 (executable)
@@ -29,13 +29,19 @@ if not modwsgi_compat:
     if not hasattr(handlermod, "wmain"):
         sys.stderr.write("ashd-wsgi: handler %s has no `wmain' function\n" % args[0])
         sys.exit(1)
-    handler = handlermod.wmain(args[1:])
+    handler = handlermod.wmain(*args[1:])
 else:
     if not hasattr(handlermod, "application"):
         sys.stderr.write("ashd-wsgi: handler %s has no `application' object\n" % args[0])
         sys.exit(1)
     handler = handlermod.application
 
+cwd = os.getcwd()
+def absolutify(path):
+    if path[0] != '/':
+        return os.path.join(cwd, path)
+    return path
+
 def dowsgi(req):
     env = {}
     env["wsgi.version"] = 1, 0
@@ -63,7 +69,7 @@ def dowsgi(req):
     if "X-Ash-Address" in req: env["REMOTE_ADDR"] = req["X-Ash-Address"]
     if "Content-Type" in req: env["CONTENT_TYPE"] = req["Content-Type"]
     if "Content-Length" in req: env["CONTENT_LENGTH"] = req["Content-Length"]
-    if "X-Ash-File" in req: env["SCRIPT_FILENAME"] = req["X-Ash-File"]
+    if "X-Ash-File" in req: env["SCRIPT_FILENAME"] = absolutify(req["X-Ash-File"])
     if "X-Ash-Protocol" in req: env["wsgi.url_scheme"] = req["X-Ash-Protocol"]
     env["wsgi.input"] = req.sk
     env["wsgi.errors"] = sys.stderr