X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=python%2Fashd%2Fwsgidir.py;h=83d96a01845d26a8e8e7a14bbfabbab779f9e5f6;hb=f677567ff38930c66cd1f447189ff738fd97daae;hp=335a5d797e6664b52832ec9b6f8836fcea9499fa;hpb=14ef1e0ed9e18ea341f21287fe9ca722985dfeee;p=ashd.git diff --git a/python/ashd/wsgidir.py b/python/ashd/wsgidir.py index 335a5d7..83d96a0 100644 --- a/python/ashd/wsgidir.py +++ b/python/ashd/wsgidir.py @@ -1,7 +1,7 @@ import os, threading, types import wsgiutil -class cachedmod: +class cachedmod(object): def __init__(self, mod, mtime): self.lock = threading.Lock() self.mod = mod @@ -54,7 +54,7 @@ def chain(path, env, startreq): entry = mod.entry else: if hasattr(mod.mod, "wmain"): - entry = mod.mod.wmain([]) + entry = mod.mod.wmain() elif hasattr(mod.mod, "application"): entry = mod.mod.application mod.entry = entry @@ -65,6 +65,13 @@ def chain(path, env, startreq): return wsgiutil.simpleerror(env, startreq, 500, "Internal Error", "Invalid WSGI handler.") exts["wsgi"] = chain +def addext(ext, handler): + p = handler.rindex('.') + mname = handler[:p] + hname = handler[p + 1:] + mod = __import__(mname, fromlist = ["dummy"]) + exts[ext] = getattr(mod, hname) + def application(env, startreq): if not "SCRIPT_FILENAME" in env: return wsgiutil.simpleerror(env, startreq, 500, "Internal Error", "The server is erroneously configured.") @@ -78,5 +85,9 @@ def application(env, startreq): return wsgiutil.simpleerror(env, startreq, 500, "Internal Error", "The server is erroneously configured.") return(exts[ext](path, env, startreq)) -def wmain(argv): +def wmain(*argv): + for arg in argv: + if arg[0] == '.': + p = arg.index('=') + addext(arg[1:p], arg[p + 1:]) return application