gnb at itga.com.au
Mon Mar 15 12:42:49 EST 2004
This is getting weirder and weirder. See FAQ 3.4 for more details! Under 2.7, I did this: <Directory /mywebdir> AddHandler python-program .py PythonDebug On PythonPath "['/mywebdir'] + sys.path" <Files "prog1.py" PythonHandler prog1 </Files> <Files "prog2.py" PythonHandler prog2 </Files> </Directory> and it all worked fine. I could use prog1.py and prog2.py as expected and the server was able to find the files to import. If I try this under 3.0.4 or 3.1.3, then it fails, with unable to import. Adding some debug code into apache.py:import_module() shows this: [Mon Mar 15 11:47:01 2004] [notice] mod_python: (Re)importing module 'mptest', s ys.path = ['mptest.py/', '/opt/python-2.3.1/lib/python23.zip', <rest of sys.path>] i.e. the PyhonPath directive is not being recognised / acted on. Weird #1: If I add the PythonPath to a wildcard files directive: <Files *.py> PythonPath "['/mywebdir'] + sys.path" </Files> <Files "prog1.py" PythonHandler prog1 </Files> Then it _sometimes_ works. And once it's worked once, then it will continue to work for the life of that apache process. Weirder #2: If I add the PythonPath to ONLY ONE of the Files entries: <Files "prog1.py" PythonHandler prog1 </Files> <Files "prog2.py" PythonHandler prog2 PythonPath "['/mywebdir'] + sys.path" </Files> Then, after a server restart, prog1.py fails. As soon as I access prog2.py for the first time, this works, and from then on prog1.py also works until the next server restart. Now I can work around this by adding a PythonPath to every <Files> section, at some cost to efficiency, but there is something very odd going on here.