mod_python req.subprocess_env 没有“看到” Python选项
我在从 apache 配置中获取环境变量时遇到问题。 (不要问为什么要这样做,我最初没有编写它)
这是我在 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'
I'm having trouble getting an environmental variable out of apache config. (don't ask why it's being done this way, I didn't originally code it)
This is what I have in the apache config.
<Location "/var/www">
SetHandler python-program
PythonHandler mod_python.publisher
PythonOption MYSQL_PWD ###########
PythonDebug On
</Location>
This is the problem code...
#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()
here is the traceback I'm getting from executing this.
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'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有关更多详细信息,请参阅 PythonOption 文档
See docs on PythonOption for more details