[mod_python] Force reload?

Graham Dumpleton grahamd at dscpl.com.au
Wed Feb 2 22:19:34 EST 2005


Jon-Pierre Gentil wrote ..
> 
> Argh!  I wish that mod_python would check all loaded modules for changes
> as a flat rule, not as a tree...  because currently it will only reload
> something if I touch the handler, because the reload code sees that the
> handler hasn't changed and does not bother checking the modules that the
> handler uses for changes.  Might as well not even use mod_python.import()
> at all.

Use Vampire and use vampire.importModule() for imports instead of "import".
In Vampire it tracks dependencies between parent/child modules and can
reimport parent modules when children change. If you look at Vampire and
want to know more, ask questions here on the mailing list.

Oh, if you are using mod_python.publisher, Vampire will require you to change
in part back to more traditional content handlers in some ways. Vampire and
some documentation can be found at:

  http://www.dscpl.com.au/projects/vampire

> Anyway, is there an option I can use to force the reload of the handler
> module each and every time a request is made?  I am only needing this for
> debugging purposes, so I don't mind something that is a bit kludgey.

In your request handler, do this:

  __mtime__ = 0

The mod_python import mechanism caches the modification time in the module
itself and so setting it to 0 will force the module to be reloaded on the next
request.

Graham


More information about the Mod_python mailing list