[mod_python] some troubles with multiple applications in the onedirectory

Graham Dumpleton grahamd at dscpl.com.au
Sun Mar 12 18:23:33 EST 2006


stalker wrote ..
> this is the part of my .htaccess file
> 
> Options -Indexes
> AddHandler mod_python .py
> <Files "test1.py">
> 	PythonHandler test1
> </Files>
> <Files "test2.py">
> 	PythonHandler test2
> </Files>
> <Files "test3.py">
>        PythonHandler test3
> </Files>
> <Files "test4.py">
>        PythonHandler test4
> </Files>
> PythonDebug On
> 
> If i get http://localhost/dir/test1.py - normal running
> if i get http://my_network_ip/dir/test1.py - i get the error
> 
> Mod_python error: "PythonHandler test1"
> ...
> ImportError: No module named test1
> 
> how can i fix it?

This problem relates to:

  https://issues.apache.org/jira/browse/MODPYTHON-126

Two things can be done to work around. The first is to explicitly
set PythonPath directive in that directory, to include that directory.
This may not be practical if you have other directories nested in
subdirectories.

The second thing that can be done is to put in a dummy fixup
handler in that directory.

  PythonFixupHandler _dummy

This should be outside of the Files directives. The _dummy.py
file should contain:

  from mod_python import apache

  def fixuphandler(req):
    return apache.OK

Use of the fixup handler is enough to trigger sys.path to be
correctly updated automatically with the path to the directory.

There is another workaround which is possibly more elegant,
but it requires use of mod_python out of subversion repository.
If I get a chance and it is of interest, I'll post about it later.

Graham


More information about the Mod_python mailing list