[mod_python] converting site from CGI to mod_python

Graham Dumpleton graham.dumpleton at gmail.com
Sun Nov 2 21:46:16 EST 2008


2008/11/3 Adam <adam at fastmail.com.au>:
>
>> Use:
>>
>>  conffile = os.path.join(os.path.dirname(__file__), "..", "config",
>> "bdns.conf")
>>  f = open(confile, 'r')
>
> Thanks for the reply.
> I did want to try and use mod_python because I think it may be interesting
> to learn. I'm not sure i entirely understand why the import_module statement
> works with relative path names but opening a file doesn't work. Does it have
> to do with the fact that mod_python scripts aren't spawned directly from
> apache as their own process.

The import_module() function is special, it internally does some
really weird stuff, looking at stack and the like to work out file in
which call was made and looking in the directory of that file before
looking in other places.

Graham


More information about the Mod_python mailing list