1 import os, threading, types
5 def __init__(self, mod, mtime):
6 self.lock = threading.Lock()
12 cachelock = threading.Lock()
28 entry = modcache[path]
29 if sb.st_mtime <= entry.mtime:
37 code = compile(text, path, "exec")
38 mod = types.ModuleType(mangle(path))
40 exec code in mod.__dict__
41 entry = cachedmod(mod, sb.st_mtime)
42 modcache[path] = entry
47 def chain(path, env, startreq):
53 if hasattr(mod, "entry"):
56 if hasattr(mod.mod, "wmain"):
57 entry = mod.mod.wmain([])
58 elif hasattr(mod.mod, "application"):
59 entry = mod.mod.application
64 return entry(env, startreq)
65 return wsgiutil.simpleerror(env, startreq, 500, "Internal Error", "Invalid WSGI handler.")
68 def application(env, startreq):
69 if not "SCRIPT_FILENAME" in env:
70 return wsgiutil.simpleerror(env, startreq, 500, "Internal Error", "The server is erroneously configured.")
71 path = env["SCRIPT_FILENAME"]
72 base = os.path.basename(path)
74 if p < 0 or not os.access(path, os.R_OK):
75 return wsgiutil.simpleerror(env, startreq, 500, "Internal Error", "The server is erroneously configured.")
78 return wsgiutil.simpleerror(env, startreq, 500, "Internal Error", "The server is erroneously configured.")
79 return(exts[ext](path, env, startreq))