2008/11/18 Seth <[EMAIL PROTECTED]>:
>
> Dear group,
>
> I'm trying to set up mod_wsgi with a new TurboGears 2 install inside a
> virtualenv. The documentation has been great, except that on Plesk
> there is one minor annoyance that requires some special configuration
> that I am having trouble with.
>
> Because Plesk overwrites any httpd.conf/httpd.include files you put in
> your virtualhosts, you have to use a special 'vhost.conf' file to add
> any configuration directives. This special file is included inside the
> <VirtualHost /> processing for each domain. That's fine for the
> WSGIScriptAlias directive, but others like WSGIPythonHome and
> WSGIPythonEggs, etc are not allowed within the VirtualHost section.
>
> How does one configure mod_wsgi for projects within virtualenv, when
> the only configuration directives you are permitted are inside of a
> VirtualHost section? Are the WSGIPythonHome/etc even required? Can
> these directives be done inside the .wsgi file instead (via
> site.addsitedir/os.environ)?
>
> Please forgive me if this is basic. I just haven't been able to find
> much help that's specific to Plesk.
WSGIPythonHome is not required. It does mean though that you will
inherit any Python packages from system wide Python site-packages
directory. If using site.addsitedir() alone in WSGI script file to add
a virtualenv directory, this can be a problem if you are trying to
provide an alternate version of a package to what is in system wide
Python site-packages directory. This is because site.addsitedir() adds
virtualenv directories to end of sys.path and so system wide Python
site-packages will take precedence.
A way around this is instead of using just site.addsitedir() use:
import sys
prev_sys_path = list(sys.path)
import site
site.addsitedir('/some/path/.../site-packages')
# Move the added items to the front of the path:
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path
This will have the affect of moving any directories added by
site.addsitedir() to the head of sys.path instead of at the end. That
way they will take precedence.
This reordering of sys.path is not done with WSGIPythonPath or
WSGIDaemonProcess python-path option in mod_wsgi 2.3, but is done in
mod_wsgi 3.0 code. If using site.addsitedir() you have to do the
reordering yourself as above.
As to WSGIPythonEggs, you can do that yourself in WSGI script file by setting:
import os
os.environ['PYTHON_EGG_CACHE'] = '/some/path/python-eggs'
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
-~----------~----~----~----~------~----~------~--~---