Graham Dumpleton
graham.dumpleton at gmail.com
Wed May 9 18:00:47 EDT 2007
Post the snippet of PSP code you are doing the import from. Post the Apache configuration snippet you are using so it can be seen whether you are setting PythonPath to include a directory which overlaps the document area and whether you are using Apache style forward slashes in paths or Windows backwards slashes. Post the snippets of the log files which show when the module is being loaded so can see the paths it is being loaded under. Especially post any warnings output about a path appearing in sys.path as well as mod_python module importer path. The only issue I know of with PSP and the new module importer is that if you use 'import' rather than 'apache.import_module()', the 'import' will always use standard Python module importer and not 'apache.import_module()'. Thus if you were trying to import a module from the same directory it by default will not work. If you fiddled PythonPath to include that directory, thus creating an overlap in the two systems, it will import but thus may be imported separately by both mechanisms. To address this latter problem, PSP needs to be changed to fake up some information in the page pseudo module so that it thinks it was imported used mod_python importer in the first place and will thus map 'import' through to 'apache.import_module()' properly. Graham On 09/05/07, Michael Sanders <m.r.sanders at gmail.com> wrote: > Environment: > - mod_python 3.3.1 > - Apache 2.2.3 running on Windows XP > - PSP request handler > > [Issue 4] described at the following link still appears to be present in > mod_python 3.3.1: > http://www.dscpl.com.au/wiki/ModPython/Articles/ModuleImportingIsBroken#line-50 > > I have a PSP file that imports a module using 'apache.import_module'. If > I re-start Apache and then fire two simultaneous requests at the PSP > file, mod_python loads the module twice. (The module in question when > imported sets up a logging handler. The initial entry written by this > module to the log file is duplicated and subsequent calls to this > handler also give duplicate entries in the log file). > > If I import the module using the standard Python 'import', this problem > does not occur. Likewise, if I use the 'vampire.importModule' method, > the problem does not occur. The issue only happens when using > 'apache.import_module'. > > Has anyone else experienced this? Is there a fix? > > Many thanks, > Michael Sanders > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python >
|