[mod_python] PSP Error & apache.import_module() questions

Graham Dumpleton grahamd at dscpl.com.au
Wed May 10 07:07:21 EDT 2006

On 10/05/2006, at 2:59 PM, Peter Sanchez wrote:

> On May 9, 2006, at 7:46 PM, Graham Dumpleton wrote:
>> Peter Sanchez wrote ..
>>> Also, I have a question on the apache.import_module() function.  
>>> Should
>>> this be done in *all* modules that are subsequently imported. IE
>>> index.py imports myconfig.py
>>> myconfig.py in turn imports sys, os and re
>>> Should myconfig.py be using apache.import_module() as well?
>>> Is there an option to do the equivilent of 'from module import  
>>> *', etc?
>> Standard Python modules should always be included with "import"  
>> and NOT
>> with "apache.import_module()".
> When should apache.import_module() be used? I am using "import" for  
> mod_python, standard python and custom modules.

Unfortunately that doesn't have a simple answer right now because of the
various issues with the module importer.

Generally, it would be used to import other modules in your document  
or modules in some separate directory which is not listed in sys.path.

In respect of importing modules from the document tree, there are issues
though if that other module is directly imported by mod_python.publisher
and you are using mod_python 3.2.X. There are comments in that article
about this issue.


More information about the Mod_python mailing list