[mod_python] import_module is case sensitive even if the OS isn't

Simon Holness simon.holness at gmail.com
Tue May 15 06:19:21 EDT 2007


On 15/05/07, Graham Dumpleton <graham.dumpleton at gmail.com> wrote:
> One can still get unexpected behaviour if there are symlinks. One
> could also apply os.path.realpath() to eliminate symlink issues on
> platforms which support them, but this would slow things down further.
> Also would break code where code assumes it can use
> os.path.dirname(__file__) to determine a bas directory as the real
> file can be in a totally different location. Thus why I don't try and
> load just one module instance where multiple symlinks point to one
> physical file.

Personally I think the issue of symlinks is a separate one and if
using them you'd expect to identify the modules based on the symlink
path not the realpath. If you create a symlink you're effectively (and
quite deliberately) creating a new path. If you make a case typo in a
config file which renders a correct and working path because the
underlying system is case insensitive, I think that's a different
kettle of fish.

> What are you expecting '~/' to resolve to? In the mod_python module
> importer '~/' is resolved to be the directory the handler was
> designated for. It should replace the '~/' with the actual value and
> if that happened to be 'c:/mypath', the final path should be the same
> and there should only be one module loaded, not two. Thus if you are
> seeing two modules may be a bug.

Sorry, I didn't explain myself clearly. The ~/ notation works fine and
generated the correct path as per spec. It just so happened that in
another handler (not in the same dir) I needed to import the module
again, so I specified the full path. Only I made a mistake and used a
lowercase 'c' for the drive letter rather than uppercase which windows
reports.

So ~/ became C:/mypath/ and I was using c:/mypath/ elsewhere (typed by hand).

On a case sensitive system that would obviously be incorrect and I'd
get an error, but in this case (NTFS) I got the module loaded twice,
with different labels.

I've seen no bugs with the ~/ notation (and it's a very handy feature!).

Cheers
Simon


More information about the Mod_python mailing list