[mod_python] mod_python 3.3.1 / python 2.5 / apache.import_module(__init__) help

Adam Venturella aventurella at gmail.com
Sun Nov 23 14:09:48 EST 2008

The docs here:

Mention this bit:

If an __init__.py file is present and it was necessary to import it to
achieve the same result as importing the root of a true Python package, then
__init__ can be used as the module name. For example:

    from mod_python import apache
    module = apache.import_module('dirname/__init__')

I think I a bit confused about how I understand it.  I read that as follows:

myModule = apache.import_module('dirname/__init__')

where dirname/ contains the following files:

and dirname/__init__.py contains:

from mod_python import apache
application = apache.import_module('application');
navigation  = apache.import_module(navigation');

So, in my mind, doing this:
myModule = apache.import_module('dirname/__init__')

should let me:

from myModule import application
from myModule import navigation

That, however, is not the case as I get an ImportError:
ImportError: No module named myModule

can someone correct my understanding of how apache.import_module(__init__)
is supposed to work / what it's benefit is?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20081123/4b232b85/attachment.html

More information about the Mod_python mailing list