[mod_python] sys.path problem

AJ Coon ajcoon at gmail.com
Wed Feb 20 21:23:49 EST 2008


Hi Graham,

I'm not using PythonPath anywhere, though my handlers both make
sys.path.append() calls to add various library paths needed by each.
Inconveniently, each of these handlers use different versions of some of the
same libraries.  It's a bit of a mess, but this all worked fine on 3.1.3.
Now that I upgraded to 3.3.1 (and changed nothing else), it's broken.
Rolling back seems the obvious choice, but I think what I'm trying to do
*is* do-able, no?


As you requested, I have included my configuration below.  I'm just
developing on a workstation and DNS is managed by /etc/hosts, hence the
.localdomain host names.  Without further adieu:

aj at aj-5150:~$ cat cat /etc/apache2/mods-enabled/mod_python.load
LoadModule python_module /usr/lib/apache2/modules/mod_python.so

aj at aj-5150:~$ cat /etc/apache2/sites-enabled/000-handlera
<VirtualHost handlera.localdomain>
    DocumentRoot /var/handlerA/www
    ScriptAlias /handlerA/ "/var/handlerA/www/handlerA_root"

    <Directory "/var/handlerA/www/handlerA_root">
    SetHandler mod_python
    PythonHandler handlerA
    PythonDebug On
    PythonAutoReload On
    PythonOption CACHE Off
    </Directory>

    ServerName handlera.localdomain

    ErrorLog /var/log/apache2/handlerA-error_log
    CustomLog /var/log/apache2/handlerA-access_log combined
</VirtualHost>

aj at aj-5150:~$ cat /etc/apache2/sites-enabled/001-handlerb
<VirtualHost handlerb.localdomain>
    DocumentRoot /var/handlerB/www
    ScriptAlias /handlerB/ "/var/handlerB/www/handlerB_root"

    <Directory "/var/handlerB/www/handlerB_root">
    SetHandler mod_python
    PythonHandler handlerB
    PythonDebug On
    PythonAutoReload On
    PythonOption CACHE Off
    </Directory>

    ServerName handlerb.localdomain

    ErrorLog /var/log/apache2/handlerB-error_log
    CustomLog /var/log/apache2/handlerB-access_log combined
</VirtualHost>

aj at aj-5150:~$ cat /var/handlerA/www/.htaccess
PythonInterpreter InterpA
Options -Indexes

aj at aj-5150:~$ cat /var/handlerB/www/.htaccess
PythonInterpreter InterpB
Options -Indexes


I hope this makes things more clear.  I hope I'm not asking for the
impossible.

-aj



On Wed, Feb 20, 2008 at 8:42 PM, Graham Dumpleton <
graham.dumpleton at gmail.com> wrote:

> Don't use PythonPath directive. Instead, read about the new module
> importer in mod_python 3.3.1 which avoids these sort of problems. See
> documentation for 'import_module()' in:
>
>   http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html
>
> To explain better, would need to see the exact configuration you are
> using for mod_python.
>
> Graham
>
> On 21/02/2008, AJ Coon <ajcoon at gmail.com> wrote:
> > Hello,
> >
> > I have an issue with two different handlers running on the same apache
> > server.
> >
> > They seem to be "sharing" (read: overwriting each other's) sys.path.
>  I'm
> > printing the output of sys.path before any of my import statements in
> each
> > handler to verify this.  It seems like I can make several requests to
> > handler "A" with no problem, but then if handler "B" is called, and then
> > subsequently handler "A" is called again, sys.path has been overwritten
> by
> > handler "B" for handler "A".  Ugh.
> >
> > - Each handler is defined in its own virtual host in apache.
> > - Each handler is named differently (i.e. PythonHandler handlerA,
> > PythonHandler handlerB)
> > - Each handler runs in its own sub-directory (i.e. /var/handlerA,
> > /var/handlerB)
> >  - In the doc root of each handler's virtual host, I have a .htaccess
> file
> > that contains a PythonInterpreter directive, defining a different named
> > interpreter to be used (i.e. PythonInterpreter InterpA,
> PythonInterpreter
> > InterpB)
> >
> >
> > How can I ensure that each handler has its own sys.path that is not
> affected
> > by the other handler, ever?
> >
> >
> > I am running on the following stack:
> >
> > Apache/2.0.54 (Debian GNU/Linux) mod_python/3.3.1 Python/2.3.5
> > mod_ssl/2.0.54 OpenSSL/0.9.7e
> >
> >
> > Thanks,
> > -aj
> >
> > _______________________________________________
> >  Mod_python mailing list
> >  Mod_python at modpython.org
> >  http://mailman.modpython.org/mailman/listinfo/mod_python
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20080220/c7bd8201/attachment-0001.html


More information about the Mod_python mailing list