[mod_python] Problems w/ mod python

Graham Dumpleton graham.dumpleton at gmail.com
Thu Apr 17 19:23:41 EDT 2008


2008/4/18 Joseph Bernhardt <joe at incomps.com>:
>
> > 2008/4/18 Joseph Bernhardt <joe at incomps.com>:
>  > >
>  > >
>  > >
>  > >
>  > > 1) How do I import a file in the same folder as the script which is
>  > > importing? This does not work:
>  > >
>  > > Is this directory in your module path?  sys.path
>  >
>  > In mod_python 3.3.1 that is not necessarily the right answer. This is
>  > because script files, such as those for mod_python.publisher are
>  > loaded with mod_python module importer. This has its own concept of
>  > path and you should not add one of those directories to sys.path and
>  > create an overlap.
>  >
>  > Either the OP's module is not readable to Apache user, or it is
>  > actually a package, in which case it needs to be moved out of document
>  > tree and then sys.path extended with directory it was put in.
>  >
>  > See documentation for import_module() in:
>  >
>  >   http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html
>  >
>  > Graham
>
>  Well, can't say I didn't try.  ;)  Thanks for clarifying, Graham.

And don't stop trying to help. Someone will need to take over from me
when I eventually vanish off this list. :-)

BTW, same applies if what is being imported is actually a C extension
module, ie., a .so file file. The mod_python module importer, for the
directories it manages, ignores both packages and C extension modules
and will only import single file based Python code modules.

Graham


More information about the Mod_python mailing list