quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael C. Neel" <n...@mediapulse.com>
Subject Re: inital questions and patches
Date Wed, 30 Jun 2004 15:29:40 GMT
On Wed, 2004-06-30 at 09:50, Gregory (Grisha) Trubetskoy wrote:

> >
> > --- mod_python/cgihandler.py    2004-02-16 13:47:27.000000000 -0600
> > +++ /usr/local/lib/python2.3/site-packages/mod_python/cgihandler.py
> > 2004-06-29 02:57:07.000000000 -0500
> > @@ -70,6 +70,7 @@
> >         dir, file = os.path.split(req.subprocess_env["script_filename"])
> >     else:
> >         dir, file = os.path.split(req.filename)
> > +    sys.path.insert(0, dir)
> >     module_name, ext = os.path.splitext(file)
> >
> >     _lock.acquire()
> 
> 
> Now this one I'm not so sure about. cgihandler will chdir into the 
> directory of the script, and '.' should be in sys.path by default.
> 
> Also, you cannot just insert things into sys.path because after ten 
> requests you'll end up with a sys.path that has ten dirs at the beginning 
> :-)
> 
> Grisha



I would like something like this for mod_python in general; every
handler we have to define a PythonPath of the handler's dir for imports
to work correctly.  To solve the lengh of sys.path issue ou can do the
following:

    if dir not in sys.path:
        sys.path.insert(0, dir)

Also, it needs to be done per interperter so that it doesn't cause issue
with other sites running though the same apache box.  3.x mp is better
in this respect than 2.x; 2.x will often confuse variables across
interpeters though I haven't found the exact cause, so this may only be
something for 3.x.

Mike

Mime
View raw message