Luke Burden
luke at demonware.net
Mon Mar 3 20:18:03 EST 2008
Hi all, I get swamped with ImportErrors when using the latest module importer with mod_python 3.3 / apache 2.2 / python 2.5. The site structure is quite flat - all the python source files in: /var/www/sitename/src/ And all the psps in: /var/www/sitename/src/psps/ The apache configuration is nothing special, and is thus: <Directory "/var/www/sitename/src"> SetHandler mod_python PythonHandler mainhandler PythonDebug On PythonInterpreter sitename </Directory> Import statements from .psp files in the psps directory are what are failing. So for example, /var/www/sitename/src/psps/page.psp might have a line, "import model", hoping to get it's sweaty hands on /var/www/sitename/src/model.py. But an ImportError will occur, of the form: ====== 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 "/var/www/sitename/src/mainhandler.py", line 290, in handler return genpages.page(req) File "/var/www/sitename/src/genpages.py", line 20, in page template.run(vars=vars) File "/usr/lib/python2.5/site-packages/mod_python/psp.py", line 243, in run exec code in global_scope File "/var/www/sitename/src/psps/page.psp", line 2, in <module> import model ImportError: No module named model ====== The frustrating thing is, in the module cache dump, you can see model.py has been loaded successfully already so it's in scope. I've tried apache directives to add the src folder to the importer path, but haven't had any success with that. Any suggestions anyone? Is there a better way of structuring modules / psps to be mod_python 3.3 compatible? Any advice really appreciated, thanks. - luke
|