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

Graham Dumpleton graham.dumpleton at gmail.com
Thu Dec 6 17:01:22 EST 2007


The mod_python module importer cannot be used on Python packages, only
Python modules. Is your software a package or a module.

Graham

On 06/12/2007, Pascal Opitz <pascal at ilikecode.co.uk> wrote:
> 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
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>


More information about the Mod_python mailing list