2009-11-02 12 views
0

J'ai des difficultés à obtenir une variable d'environnement à partir de la configuration apache. (ne demandez pas pourquoi c'est fait de cette façon, je ne l'ai pas codé à l'origine)mod_python req.subprocess_env pas "seeing" PythonOptions

C'est ce que j'ai dans la configuration apache.

<Location "/var/www"> 
    SetHandler python-program 
    PythonHandler mod_python.publisher 
    PythonOption MYSQL_PWD ########### 
    PythonDebug On 
</Location> 

Ce code est le problème ...

#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() 

est le retraçage ici, je suis en train d'exécuter ce.

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' 

Répondre