#!/usr/bin/python
import sys, os, getopt, threading
-import ashd.proto
+import ashd.proto, ashd.util
def usage(out):
out.write("usage: ashd-wsgi [-hA] [-p MODPATH] HANDLER-MODULE [ARGS...]\n")
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
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
def handle(req):
reqthread(req).start()
-ashd.proto.serveloop(handle)
+ashd.util.serveloop(handle)