[mod_python] Graham's New Importer

Dan Eloff dan.eloff at gmail.com
Tue May 9 11:40:50 EDT 2006


I think probably just:

PythonOption importer.path "C:\Documents And Settings\..." "another path"

I'm not sure the syntax allows for that, but something along those
lines is the idea. None of those paths should be on sys.path.

You shouldn't be able to specify this more than once for each python
interpreter. I don't know how to enforce that, but it would prevent
any wierdness with the same module being imported under different
circumstances in the same interpreter.

The paths should be used for all importing done by that interpreter,
and should be added to sys.path temporarily if you fallback to
python's import so that those modules can still be found.

There's probably some problems with all this, but I don't think
anything insurmountable, and you're no doubt familiar enough with the
system to spot the trouble before we start.

-Dan



On 5/8/06, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> Dan Eloff wrote ..
> > Hey Graham, I've been using your new module importer and it works like
> > a charm. I haven't had a single problem with it. Thanks!
> >
> > I would like to discuss having a general search path, and being able
> > to add directories to it. While I understand the reasons you have (and
> > they are valid, good reasons) for not wanting to do this, there are
> > also good reasons to have the ability. Right now, so I don't have to
> > stick the absolute path to pyserver components in every file, I've
> > moved pyserver to site-packages, giving up the reload ability. It also
> > prevents me from using the debugger without restarting the server. I
> > also find that I have some common includes off sys.path and I've sunk
> > to placing the absolute path in an extraneous module and importing
> > that whenever I need to import these common files so as to avoid
> > sticking the path everywhere. It's less than ideal. I think it would
> > really be a nice touch to be able to choose which behaviour you want.
> > Just add a PythonOption called search_path or import_path or
> > something, and if given the directories listed get added to the search
> > path for all importing needs.
> >
> > If you're not interested I'll add this, but I would want your
> > permission first before I go messing with your code.
> >
> > That aside, don't let my suggestion for improvement detract in any way
> > from your importer, it's really a great piece of work.
>
> This discussion should perhaps be on the developers mailing list, here
> will do for the moment though.
>
> Now, before you contemplate making any code changes, just outline at a
> high level what options/directives you have in mind should be added and
> what defining them should cause to happen.
>
> In the mean time, I'll have to go back and read what I rambled on about
> last time as I forget. I don't think though that I revealed everything you
> could do and although some of the stuff I didn't mention may not be
> directly useful, it may well form basis of implementing such stuff.
>
> Will be interested to here how you think such global search paths should
> work. After all, you are probably the first to try and seriously use the
> new importer in the new ways that it can be used.
>
> Anyway, will see what you have to say and make comments if appropriate.
>
> Graham
>



More information about the Mod_python mailing list