mod_python与flask框架搭配使用问题,mod_pythonflask,在win下使用xampp


在win下使用xampp,并且安装了mod_python,然后使用flask给的例子,使用以下方法调用函数。

def handler(req):    req.content_type='text/plain'    init_db()    app.run()    return apache.OK

例子为:https://github.com/mitsuhiko/flask/tree/master/examples/flaskr/

apache的http.conf加入了以下代码

<Directory "D:/xampp/htdocs/python/flaskr">AllowOverride FileInfoSetHandler python-programAddHandler mod_python .pyPythonAutoReload OnPythonHandler flaskrPythonDebug On

然后访问localhost/python/flaskr报错

MOD_PYTHON ERROR

ProcessId: 9880 Interpreter: 'localhost'

ServerName: 'localhost' DocumentRoot: 'D:/xampp/htdocs'

URI: '/python/flaskr/' Location: None Directory: 'D:/xampp/htdocs/python/flaskr/' Filename: 'D:/xampp/htdocs/python/flaskr/' PathInfo: ''

Phase: 'PythonHandler' Handler: 'flaskr'

Traceback (most recent call last):

File "C:\Python27\lib\site-packages\modpython\importer.py", line 1537, in HandlerDispatch default=defaulthandler, arg=req, silent=hlist.silent)

File "C:\Python27\lib\site-packages\modpython\importer.py", line 1202, in _processtarget module = importmodule(modulename, path=path)

File "C:\Python27\lib\site-packages\modpython\importer.py", line 296, in importmodule log, import_path)

File "C:\Python27\lib\site-packages\modpython\importer.py", line 680, in importmodule execfile(file, module.dict)

File "D:\xampp\htdocs\python\flaskr\flaskr.py", line 35, in app.config.from_object(name)

File "C:\Python27\lib\site-packages\flask\config.py", line 162, in fromobject obj = importstring(obj)

File "C:\Python27\lib\site-packages\werkzeug-0.8.3-py2.7.egg\werkzeug\utils.py", line 411, in importstring return import(importname)

ImportStringError: importstring() failed for 'mp_d645bbbdbf6c8b566289f00aa0ab7147'. Possible reasons are:

missing init.py in a package;package or module path not included in sys.path;duplicated package or module name taking precedence in sys.path;missing module, class, function or variable;

Debugged import:

'mpd645bbbdbf6c8b566289f00aa0ab7147' not found.

Original exception:

ImportError: No module named mpd645bbbdbf6c8b566289f00aa0ab7147

MODULE CACHE DETAILS

Accessed: Tue May 07 18:04:34 2013 Generation: 0

mpd645bbbdbf6c8b566289f00aa0ab7147 { FileName: 'D:\xampp\htdocs\python\flaskr\flaskr.py' Instance: 1 [IMPORT] Generation: 0 [ERROR] Modified: Tue May 07 16:28:18 2013 }

编橙之家文章,

评论关闭