[mod_python] import module via publisher

piet at cs.uu.nl piet at cs.uu.nl
Tue Jun 26 05:27:25 EST 2001

>>>>> richard hitier <richard.hitier at idealx.com> (RH) wrote:

RH> in fact, from now on I can tell two points:
RH> (remember I work whith the publisher)

RH> 1º    calling http://my_page/module/fonction

RH> always give me the latest modifications results (whithout restarting
RH> apache at all)

That is because mod_python has special code to check if the module has
changed and should be reloaded.

RH> 2º     But if I call some imported code in my module.fonction()
RH> this will never be updated according to imported module file last
RH> modifications.

That is because you do not use this special check yourself.
You can do:

module = apache.import_module(module_name)

RH> * Le  19 Jun >Jonas Meyer Rasmussen< ecrivait:
>> import my.module
>> def handler( req ):
>> reload( my.module )
RH> I can't do that since that I'm porting code from zope app to apache app.
RH> And, they import name instead of module:

RH>     from foreign_module import my_name

RH> and this (afaik) canot be reloaded in python.

Yes, you can do it again after reloading the module:

foreign_module = apache.import_module("foreign_module")
from foreign_module import my_name
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl

More information about the Mod_python mailing list