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

Graham Dumpleton grahamd at dscpl.com.au
Tue May 9 22:46:58 EDT 2006


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()".

Also, a general rule is that you should not import the same module using
both "import" and "apache.import_module()" from different places. If you
break this rule, you can end up with modules being wrongly reloaded
which can cause problems. See:

  http://www.dscpl.com.au/articles/modpython-003.html#redundant-module-loading

You may want to read that whole article, as it describes various other
module importing issues when using mod_python.

Graham


More information about the Mod_python mailing list