[mod_python] import_module

Adrien Plisson adrien.plisson at kawaiidream.org
Wed Apr 14 15:46:37 EST 2004


Kamil Niechajewicz wrote:

> 1. We enter site at url http://localhost/  -> page shows correctly content
> generated by /app_root/index.py. The module index.py is loaded.

here, the module "/app_root/index.py" is imported.

> 2. We enter site at url http://localhost/admin  -> page shows correctly 
> content generated by /app_root/admin/index.py 

at this second step, the module "/app_root/admin/index.py" is imported.

> 3. We enter site at url http://localhost/ again -> page shows content of
> /app_root/admin/index.py, because reimporting module 'index' does not
> occur - module_import checks that module is loaded, checks its mtime and
> decides not to reimport it, so we end with 'index' module from a wrong
> 'package'.

now note that "/app_root/admin/index.py".startswith( "/app_root/" ) == True as 
well as, "/app_root/index.py".startswith( "/app_root/" ) == True

as you pointed in one of your previous mail, it may be a matter of using 

take a first module, already imported.
take a second module given the same name as the first, residing in any parent 
directory of the first module.
the path of the first module will always "startswith" the path of the second 
one. and their name will be equals. thus, the second module will not be 
imported, the first module will be used instead.

I don't have a modpython right at my hand to test this, nor do i know 
modpython's internals, so i may be wrong. if anyone could test...



More information about the Mod_python mailing list