[mod_python] mod_python weirdness, maybe related to importing?

Sean Reifschneider jafo at tummy.com
Sun Jun 15 18:54:19 EST 2003

On Mon, Jun 16, 2003 at 10:25:38AM +1000, Gregory Bond wrote:
>>    include current directory in path
>>    module = __import__(basename, globals(), locals(), [])
>>    return sys.path to old layout
>This might be your problem.  Inside mod_python the current directory is 
>probably "/".  It's not like CGI where the current directory is the CGI dir.

By "current" directory, I mean the directory that I am currently looking
for the module in.  For example, the directory in "filename" the request

My problem isn't that it's not importing the module.  The problem is
that it seems like mod_python has done something weird and possibly just
wrong with the import semantics, so that if I import a package, modules
within that package aren't available unless I explicitly import them in
the init.

Also, I'm running into cases where I'm setting values within modules in
my handler, and then when I call code in the module those values are
reset.  I've resorted to shoving request-persistent data into
__builtins__, which works around the latter problem, and re-structuring
some code so that my entire object heirarchy *CAN* be imported all at

 -rw-rw-rw-:  File permissions of the beast.  (Chuck Phillips)
 mknod /dev/beast c 6 66
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995.  Qmail, Python, SysAdmin

More information about the Mod_python mailing list