apache config から環境変数を取得するのに問題があります。(なぜこのように行われるのかは聞かないでください。もともと私がコーディングしたわけではありません)
これは私がApache構成に持っているものです。
<Location "/var/www">
SetHandler python-program
PythonHandler mod_python.publisher
PythonOption MYSQL_PWD ###########
PythonDebug On
</Location>
これが問題のコードです...
#this is the problem code in question.
def index(req):
req.add_common_vars()
os.environ["MYSQL_PWD"] = req.subprocess_env["MYSQL_PWD"]
req.content_type = "text/html"
statText = getStatText()
これは、これを実行して取得したトレースバックです。
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1229, in _process_target
result = _execute_target(config, req, object, arg)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1128, in _execute_target
result = object(arg)
File "/usr/lib/python2.5/site-packages/mod_python/publisher.py", line 213, in handler
published = publish_object(req, object)
File "/usr/lib/python2.5/site-packages/mod_python/publisher.py", line 425, in publish_object
return publish_object(req,util.apply_fs_data(object, req.form, req=req))
File "/usr/lib/python2.5/site-packages/mod_python/util.py", line 554, in apply_fs_data
return object(**args)
File "/var/www/admin/Stat.py", line 299, in index
os.environ["MYSQL_PWD"] = req.subprocess_env["MYSQL_PWD"]
KeyError: 'MYSQL_PWD'