[Python-Dev] New and Improved Import Hooks
Samuele Pedroni
pedronis@bluewin.ch
Tue, 3 Dec 2002 21:43:11 +0100
From: "Just van Rossum" <just@letterror.com>
> Samuele Pedroni wrote:
>
> > From: "Just van Rossum" <just@letterror.com>
> > > I will change my zipimport hook (which _still_ isn't finished ;-) to also
> > > traverse sys.path, and check for *.zip path endings.
> > >
> >
> > my point was that, given
> >
> > dir1;zip0;dir2
> >
> > dir1 should take over zip0 that should take over dir2.
> >
> > [This is what Jython 2.1 does btw]
> >
> > If the resulting import precedence order is that both dir1 and dir2 take
over
> > zip0, then maybe allowing zip0 in sys.path is just confusing,
> > and zipfiles should be specified elsewhere.
>
> True, true.
>
> Does Jython implement the (old) idea that items on sys.path can be import
> handler *objects*? (If yes, can you briefly describe the interface of these
> objects?)
>
No jython accepts strings of the form *.zip in sys.path, that are converted
upon scanning on import to string subclasses' instances with the same value as
string, through which import happens using an internal interface implemented by
these string subclasses.
We also set __path__s to contain things of the form *.zip/rel/path/to/package.
regards.