[mod_python] PythonPath and importer in 3.3

Graham Dumpleton grahamd at dscpl.com.au
Sun Feb 11 00:56:10 EST 2007

Dirk van Oosterbosch, IR labs wrote ..
> However, I am not sure I am 100% happy with adding the path to the  
> templates directory to the directive in httpd.conf. I rather add the  
> extra module-search-directories in the hander module (main.py in my  
> case) itself, possibly determining which directory is extra needed,  
> based on the request. Is there a function to add to the importer path 
> from a module itself?

Back in an airport again for a half hour shuttle flight.

You can do what you want by changing 'mod_python.importer.path'
from within the handler itself before any call to import_module().

  options = req.get_options()
  path = eval(options.get('mod_python.importer.path', []))
  options['mod_python.importer.path'] = str(path)

At my next stop I should have Internet access again if ADSL install
we requested has been done properly. :-)


More information about the Mod_python mailing list