On 18/05/07, Daniel J. Popowich <[EMAIL PROTECTED]> wrote:
Graham Dumpleton writes: > > When I go to http://localhost/~dpopowich/py/syspath, a simple > > mpservlet that writes out the current value of sys.path, I do NOT see > > /home/dpopowich/public_html/py in the path. > > You will not see the path listed in sys.path. The mod_python module > importer path and the Python sys.path are deliberately kept separate > because of all the problems caused by each looking in the same > location. But I did see the path in sys.path before 3.3. Prior to 3.3, the directory that contained the SetHandler directive would be in sys.path. I have no idea if this behaviour in versions <3.3 is because of the old apache.import_module or some other "feature," but it's not there in 3.3.
And that is what the documentation I pointed you at states: """Note that with the new module importer, as directories associated with Python*Handler directives are no longer being added automatically to sys.path and they are instead used directly by the module importer only when required, some existing code which expected to be able to import modules in the handler root directory from a module in a subdirectory may no longer work. In these situations it will be necessary to set the mod_python module importer path to include '~' or list '~' in the __mp_path__ attribute of the module performing the import.""" This was immediately below the example line I referred you to go look for. If one wants to be precise, the addition of the handler directory to sys.path was actually done by the top level mod_python dispatch code rather than the module importer itself. The other important bit is: """As a new feature in mod_python 3.3, when using the standard Python 'import' statement to import a module, if the import is being done from a module which was previously imported by the mod_python module importer, it is equivalent to having called apache.import_module() directly.""" It is because of this that the directory doesn't need to be in sys.path, as under the covers, when 'import' is being used by modules imported by the mod_python module importer directly in some way, then 'import' is equivalent to having used 'apache.import_module()' and therefore it looks in places related to mod_python including stuff in the separate mod_python importer path.
> > And when I try to import > > a python module in that directory, I get import errors. > > If you are still using the old module importer in mpservlets to import > your .mps file then that would probably still occur. No. I do NOT use apache.import_module() to load .mps files. I rolled my own, using execfile on the filename coming from req.filename.
When I said 'old module importer' in that case, I meant your hand rolled one in mpservlets, not the old mod_python one. Graham