[mod_python] ImportError with https

Richard Boardman richboardman at gmail.com
Thu Dec 1 05:16:43 EST 2005


Greetings,

Apologies if this has appeared twice; my other email account is having
some trouble at the moment and it would appear that this message didn't
make it to the list.

I'm having an issue with HTTPS and mod_python. If I create some python
file /var/www/foobarsite/foo.py:

   from mod_python import apache

   def handler(req):
       req.write('This is a test\n')
       return apache.OK

then having the file /var/www/foobarsite/.htaccess reading:

   AddHandler python-program .py
   PythonDebug On
   <Files "foo.py">
     PythonHandler foo
   </Files>
   <Files "bar.py">
     PythonHandler bar
   </Files>
   # etc.

then there is no problem when I visit the site through my browser with 
an HTTP prefix; as expected, the text "This is a text" appears in the 
browser window. My issue is this: if I access this with the https://... 
prefix, the following error is yielded:

   Mod_python error: "PythonHandler foo"

   Traceback (most recent call last):

     File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line 
320,
   in HandlerDispatch
       module = import_module(module_name, config)

     File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line 
496,
   in import_module
       f, p, d = imp.find_module(parts[i], path)

   ImportError: No module named foo

To the best of my knowledge, the server on which this resides is 'fine'
with HTTPS (other people have set this up): if I create a file foo.html
with a similar text, then this works fine with https as the prefix.

Is there something obvious I'm doing wrong? From the error it seems as
though the '.' directory is not in the path (!) - mod_python (and
consequently python) appear to be executing. I've given the file
permissions and directory permissions a cursory tweak (+x, -x) but this
doesn't make a difference [granted, this is clutching at straws].

The server purports to be running Apache/2.0.52 (Unix), mod_ssl/2.0.52, 
OpenSSL/0.9.7a, mod_python/3.0.3 and Python/2.2.2.

If it's just a simple tweak needed in the .htaccess file, then that's
ideal, but all suggestions gratefully received :)

Thanks in advance,

Rich



More information about the Mod_python mailing list