On 7 September 2010 21:00, Sandip Bhattacharya <[email protected]> wrote: > I was just going through Graham's wonderful presentation on WSGI at > http://blip.tv/file/3840484 in which he talks about the problem of > using virtualenv with mod_wsgi, and how the 'site' module partially > solves this problem, even though not entirely without some > uncomfortable side-effects. > > My hosting provider (Dreamhost) provides a Passenger based wsgi > feature (http://wiki.dreamhost.com/Passenger_WSGI). > > I have been able to use the following in the top of my wsgi file in > such an environment to use the modules in my virtualenv. > > INTERP = "/path/to/virtualenv/bin/python" > if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv) > > I haven't tried it yet, though. It works for me there, and I haven't > had any PYTHONPATH based issues.
I don't remember how Phusion Passenger works as far as loading the WSGI script, but the above code to me looks like a dangerous way of doing it given that it execs the Python interpreter a second time. This approach will also simply not work with Apache/mod_wsgi. Personally cant see what is wrong with what was given in my presentation which was: activate_this = os.path.join(root,'/path/to/virtualenv/bin/activate_this.py') execfile(activate_this, dict(__file__=activate_this)) This is much safer and would work with any Python hosting mechanism. Graham -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
