Mercurial > p > roundup > code
comparison roundup/cgi/apache.py @ 2944:835ac4013578
added options TrackerDebug and TrackerTiming;
by default, start the tracker optimized
| author | Alexander Smishlajev <a1s@users.sourceforge.net> |
|---|---|
| date | Mon, 22 Nov 2004 07:33:34 +0000 |
| parents | 353dc16a49b2 |
| children | e8d4ac23692f |
comparison
equal
deleted
inserted
replaced
| 2943:996e2bab8d8a | 2944:835ac4013578 |
|---|---|
| 18 # to open the tracker | 18 # to open the tracker |
| 19 # 06-may-2004 [als] use cgi.FieldStorage from Python library | 19 # 06-may-2004 [als] use cgi.FieldStorage from Python library |
| 20 # instead of mod_python FieldStorage | 20 # instead of mod_python FieldStorage |
| 21 # 29-apr-2004 [als] created | 21 # 29-apr-2004 [als] created |
| 22 | 22 |
| 23 __version__ = "$Revision: 1.3 $"[11:-2] | 23 __version__ = "$Revision: 1.4 $"[11:-2] |
| 24 __date__ = "$Date: 2004-10-23 14:13:24 $"[7:-2] | 24 __date__ = "$Date: 2004-11-22 07:33:34 $"[7:-2] |
| 25 | 25 |
| 26 import cgi | 26 import cgi |
| 27 import os | 27 import os |
| 28 | 28 |
| 29 from mod_python import apache | 29 from mod_python import apache |
| 74 def handler(req): | 74 def handler(req): |
| 75 """HTTP request handler""" | 75 """HTTP request handler""" |
| 76 _options = req.get_options() | 76 _options = req.get_options() |
| 77 _home = _options.get("TrackerHome") | 77 _home = _options.get("TrackerHome") |
| 78 _lang = _options.get("TrackerLanguage") | 78 _lang = _options.get("TrackerLanguage") |
| 79 _timing = _options.get("TrackerTiming", "no") | |
| 80 if _timing.lower() in ("no", "false"): | |
| 81 _timing = "" | |
| 82 _debug = _options.get("TrackerDebug", "no") | |
| 83 _debug = _debug.lower not in ("no", "false") | |
| 79 if not (_home and os.path.isdir(_home)): | 84 if not (_home and os.path.isdir(_home)): |
| 80 apache.log_error( | 85 apache.log_error( |
| 81 "PythonOption TrackerHome missing or invalid for %(uri)s" | 86 "PythonOption TrackerHome missing or invalid for %(uri)s" |
| 82 % {'uri': req.uri}) | 87 % {'uri': req.uri}) |
| 83 return apache.HTTP_INTERNAL_SERVER_ERROR | 88 return apache.HTTP_INTERNAL_SERVER_ERROR |
| 84 _tracker = roundup.instance.open(_home) | 89 _tracker = roundup.instance.open(_home, not _debug) |
| 85 # create environment | 90 # create environment |
| 86 # Note: cookies are read from HTTP variables, so we need all HTTP vars | 91 # Note: cookies are read from HTTP variables, so we need all HTTP vars |
| 87 req.add_common_vars() | 92 req.add_common_vars() |
| 88 _env = dict(req.subprocess_env) | 93 _env = dict(req.subprocess_env) |
| 89 # XXX classname must be the first item in PATH_INFO. roundup.cgi does: | 94 # XXX classname must be the first item in PATH_INFO. roundup.cgi does: |
| 90 # path = string.split(os.environ.get('PATH_INFO', '/'), '/') | 95 # path = string.split(os.environ.get('PATH_INFO', '/'), '/') |
| 91 # os.environ['PATH_INFO'] = string.join(path[2:], '/') | 96 # os.environ['PATH_INFO'] = string.join(path[2:], '/') |
| 92 # we just remove the first character ('/') | 97 # we just remove the first character ('/') |
| 93 _env["PATH_INFO"] = req.path_info[1:] | 98 _env["PATH_INFO"] = req.path_info[1:] |
| 99 if _timing: | |
| 100 _env["CGI_SHOW_TIMING"] = _timing | |
| 94 _form = cgi.FieldStorage(req, environ=_env) | 101 _form = cgi.FieldStorage(req, environ=_env) |
| 95 _client = _tracker.Client(_tracker, Request(req), _env, _form, | 102 _client = _tracker.Client(_tracker, Request(req), _env, _form, |
| 96 translator=TranslationService.get_translation(_lang, | 103 translator=TranslationService.get_translation(_lang, |
| 97 tracker_home=_home)) | 104 tracker_home=_home)) |
| 98 _client.main() | 105 _client.main() |
