[mod_python] Newbie question: Custom module path not taken over by importer

Pascal Opitz pascal at ilikecode.co.uk
Thu Dec 6 07:23:43 EST 2007


Hello, first of all apologies if I ask something really stupid and
simple, but I searched the list and tried various scenarios, but
Nothing worked.

I set up a Fedora 8 VM and got that running with:
httpd.i386                               2.2.6-3                installed
mod_python.i386                          3.3.1-5                installed
python.i386                              2.5.1-15.fc8           installed

Then I added a directory that should have custom modules, and now try
to pass that into mod_python via the httpd.conf, which with the new
importer (if I read that right) should be like this:

<VirtualHost *:80>
        ServerName demosite
        SetHandler mod_python
        PythonOption mod_python.importer.path
["/home/developer/projects/common/python/modules"]
        PythonHandler testmodule::hello_world
        PythonDebug On
</VirtualHost>

I also tried the old (? did I understand that right) way of utilizing
PythonPath:

<VirtualHost *:80>
        ServerName demosite
        SetHandler mod_python
        PythonPath "['/home/developer/projects/common/python/modules']"
        PythonHandler testmodule::hello_world
        PythonDebug On
</VirtualHost>

If I mode the testmodule into the site-packages directory, it works.
However, if I have it in
/home/developer/projects/common/python/modules/testmodule, and chmod
it with 777, it won't be picked up. Instead I get an error:

MOD_PYTHON ERROR

ProcessId: 2944
Interpreter: 'demosite'

ServerName: 'demosite'
DocumentRoot: '/var/www/html'

URI: '/'
Location: None
Directory: None
Filename: '/var/www/html/'
PathInfo: ''

Phase: 'PythonHandler'
Handler: 'testmodule::hello_world'

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
1202, in _process_target
 module = import_module(module_name, path=path)

 File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
304, in import_module
 return __import__(module_name, {}, {}, ['*'])

ImportError: No module named testmodule




Anything in my newbie attempt that is obviously wrong?
Best


Pascal


More information about the Mod_python mailing list