[mod_python] Udate python modules without restarting Apache

Graham Dumpleton grahamd at dscpl.com.au
Fri Oct 8 08:30:11 EDT 2004


On Friday, October 8, 2004, at 07:09  AM, berry groenendijk wrote:

> There is indeed very little information on the Internet about the
> apache.import_module funtion. I did find this Wiki page:
> http://modpython.coedit.net/ReloadingModules
>
> I now import all my Python modules using apache.import_module, except
> for all the Standard Library imports. All indirectly imported modules
> are also imported with apache.import_module. In my .htaccess file I
> have set PythonAutoReload On.
>
> But, when I make a change in a module, save it and refresh my browser,
> the module is NOT reloaded. Why? Has anyone succefully used
> apache.import_module?

Is the module you change one that is directly listed in a PythonHandler
directive, or if using mod_python.publisher, is it a module which is
being directly loaded by mod_python.publisher?

If it isn't and it is one of your common modules which is imported by
one falling into the above class of modules, then you still may at
least need to touch all the top level modules which use it. This is
because import_module() will not reload a top level module if what is
changed is actually in a module it imports.

Ie., if a.py imports b.py using import_module() and b.py is changed, but
then access is to a.py for the web page, neither a.py nor b.py will be
imported. You need to touch a.py first as well. If I understand things
correctly, it should then import a.py again, which in turn, since b.py
was modified should see import_module() import it as well.

What content handler system are you using, publisher, psp, home grown?
Can you describe how the modules/files relate and what is being changed?

--
Graham Dumpleton (grahamd at dscpl.com.au)



More information about the Mod_python mailing list