Graham Dumpleton
graham.dumpleton at gmail.com
Mon Mar 3 20:53:12 EST 2008
On 04/03/2008, Luke Burden <luke at demonware.net> wrote: > Thanks for pointing me to that, Graham. > > That's quite a significant change .. is it meant to be a strong hint > that we shouldn't be importing from within .psp files? No. > The fix described - is it necessary to setup the magic variables that > the import statement looks to use per PSP, or are these mod_python > module variables we can set once and so avoid having to change code? The mod_python code should be changed. The code should have been in mod_python 3.3.1 to begin with but got missed. It should make it into a future version whenever that might be done. No one is really active on mod_python development at the moment so not sure when that might be. > What is the better path to take here for future compatibility? The > magic variable path, or the user of apache.import_module("module")? Ideally 'import' should just work as it always used to, thus why it is better that patch be made to mod_python code. Graham > Much appreciated .. > > - luke > > > On 3/3/08, Graham Dumpleton <graham.dumpleton at gmail.com> wrote: > > Apply fix in: > > > > https://issues.apache.org/jira/browse/MODPYTHON-220 > > > > Graham > > > > > > On 04/03/2008, Luke Burden <luke at demonware.net> wrote: > > > Hi all, > > > > > > I get swamped with ImportErrors when using the latest module importer > > > with mod_python 3.3 / apache 2.2 / python 2.5. > > > > > > The site structure is quite flat - all the python source files in: > > > /var/www/sitename/src/ > > > > > > And all the psps in: > > > > > > /var/www/sitename/src/psps/ > > > > > > The apache configuration is nothing special, and is thus: > > > > > > <Directory "/var/www/sitename/src"> > > > SetHandler mod_python > > > PythonHandler mainhandler > > > PythonDebug On > > > PythonInterpreter sitename > > > </Directory> > > > > > > Import statements from .psp files in the psps directory are what are failing. > > > So for example, /var/www/sitename/src/psps/page.psp might have a line, > > > "import model", hoping to get it's sweaty hands on > > > /var/www/sitename/src/model.py. But an ImportError will occur, of the > > > form: > > > > > > ====== > > > Traceback (most recent call last): > > > > > > File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line > > > 1537, in HandlerDispatch > > > default=default_handler, arg=req, silent=hlist.silent) > > > > > > File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line > > > 1229, in _process_target > > > result = _execute_target(config, req, object, arg) > > > > > > File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line > > > 1128, in _execute_target > > > result = object(arg) > > > > > > File "/var/www/sitename/src/mainhandler.py", line 290, in handler > > > return genpages.page(req) > > > > > > File "/var/www/sitename/src/genpages.py", line 20, in page > > > template.run(vars=vars) > > > > > > File "/usr/lib/python2.5/site-packages/mod_python/psp.py", line 243, in run > > > exec code in global_scope > > > > > > File "/var/www/sitename/src/psps/page.psp", line 2, in <module> > > > import model > > > > > > ImportError: No module named model > > > ====== > > > > > > The frustrating thing is, in the module cache dump, you can see > > > model.py has been loaded successfully already so it's in scope. > > > > > > I've tried apache directives to add the src folder to the importer > > > path, but haven't had any success with that. > > > Any suggestions anyone? Is there a better way of structuring modules > > > / psps to be mod_python 3.3 compatible? Any advice really > > > appreciated, thanks. > > > > > > - luke > > > > > _______________________________________________ > > > Mod_python mailing list > > > Mod_python at modpython.org > > > http://mailman.modpython.org/mailman/listinfo/mod_python > > > > > > > > ______________________________________________________________________ > > This email has been scanned by the MessageLabs Email Security System. > > For more information please visit http://www.messagelabs.com/email > > ______________________________________________________________________ > > > > ______________________________________________________________________ > > This email has been scanned by the MessageLabs Email Security System. > > For more information please visit http://www.messagelabs.com/email > > ______________________________________________________________________ > > >
|