Graham Dumpleton writes: > Correct, you were only changing the path related to modules managed by > the new module importer and not those handled by the standard Python > importer. Adding "~" like that would also only have been needed if in > a subdirectory of the handler root directory an import was trying to > be done with either 'import' or 'apache.import_module()' for a module > in the handler root directory. > > I had assumed in suggesting that, that you had already converted > mpservlets to use the new module importer and were triggering that > specific case.
Graham, Thanks for your detailed answers (as always). Very helpful. However, something I said in my original email is, I think, clouding the issue, at least for me as I read your responses (or perhaps I'm just not being very clear in my questions): I had said in passing I was picking up mod_python again and thought I'd rewrite my mpservlets importer to use the new 3.3 apache.import_module() function. **I actually never got that far.** I upgraded my apache to use mp3.3 and the first thing I did was run my tutorial and what I got was import errors. So, to sum up: o I have never used apache.import_module(), old or new. I only use the import builtin. o I have NOT started rewriting mpservlets to use the new importer. In fact, I have NOT touched any old code at all: just upgrade to 3.3 and run what I've always run. o My configuration uses .htaccess with: SetHandler mod_python PythonHandler mod_python.servlet PythonDebug on o What I have is a servlet (mps file) that gets found just fine with my importer, but when execfile is run on the file I get import errors on the **imports INSIDE the mps file** because sys.path does not contain the handler directory like it used to. I have confirmed that adding "PythonOption mod_python.legacy.importer *" "fixes" the problem. So, if I'm not from ever-on going to use legacy switches, what in your opinion is the solution? Are you suggesting that if I use the 3.3 importer to load my mps files then the imports inside the mps files will automagically work? Thanks, Dan PS It should have been named 4.0. Having to turn on legacy switches or rewrite code to handle changes in functionality screams: This Is Not A Minor Upgrade. PPS For completeness here's the exception I get when I upgraded to 3.3 and the first thing I did was load the homepage to my mps tutorial: ---------------------------------------------------------------------- MOD_PYTHON ERROR ProcessId: 7363 Interpreter: 'io.astro.umass.edu' ServerName: 'io.astro.umass.edu' DocumentRoot: '/var/www/' URI: '/~dpopowich/mpstutorial/index' Location: None Directory: '/home/dpopowich/public_html/mpstutorial/' Filename: '/home/dpopowich/public_html/mpstutorial/index' PathInfo: '' Phase: 'PythonHandler' Handler: 'mod_python.servlet' Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch default=default_handler, arg=req, silent=hlist.silent) File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1229, in _process_target result = _execute_target(config, req, object, arg) File "/usr/lib/python2.4/site-packages/mod_python/importer.py", line 1128, in _execute_target result = object(arg) File "/usr/lib/python2.4/site-packages/mod_python/servlet.py", line 1456, in handler servlet = _sm.get_servlet(filename) File "/usr/lib/python2.4/site-packages/mod_python/servlet.py", line 1353, in get_servlet klass, servlets = self.__load_servlet(filename) File "/usr/lib/python2.4/site-packages/mod_python/servlet.py", line 1270, in __load_servlet execfile(fname, code) File "/home/dpopowich/public_html/mpstutorial/index.mps", line 3, in ? from _TutorialBase import * ImportError: No module named _TutorialBase ----------------------------------------------------------------------