Christopher Arndt wrote:
> Lukasz Szybalski schrieb:
> > On Wed, Jul 30, 2008 at 9:03 AM, Christoph Zwerschke <c
...@online.de> wrote:
> >> So ideally, I'd like to allow both kinds of URLs for my applications at
> >> the same time. But the problem is that you can set only one root path in
> >> TG using server.webpath.
> > Is there a reason you are not using mod_wsgi deployment to achieve above ?
> That's beside the question. Or can you show a way to solve the original
> problem (running the application under two different webpaths) with
> mod_wsgi?
The issue is whether TG is a true WSGI friendly application or not. If
TG is a good WSGI citizen, then it should honour the SCRIPT_NAME
variable passed in by a WSGI adapater as being the mount point of the
application. That is, SCRIPT_NAME should be used in preference to
server.webpath, especially if server.webpath is not defined.
If TG honours this, then using mod_wsgi one could do the following:
# Create WSGIDaemonProcess outside of VirtualHost so can be
# delegated to by mulitple virtual hosts.
WSGIDaemonProcess appname
# Allow access to WSGI script file for application.
<Directory /usr/local/turbogears/mysite/apache>
# Delegate this TG application to 'appname' daemon process and
# specifically the main interpreter in that process. Need to specify
# application group else different mount points across virtual hosts
# would result in there being multiple instances in process. Forcing
# it to main interpreter means there will be only one instance of
# application regardless of where it is mounted.
WSGIProcessGroup appname
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
# Virtual host for appname.company.com.
<VirtualHost *:80>
ServerName appname.company.com
WSGIProcessGroup appname
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /usr/local/turbogears/mysite/apache/
turbogears.wsgi
</VirtualHost>
# Virtual host for main company site.
<VirtualHost *:80>
ServerName www.company.com
WSGIScriptAlias /appname /usr/local/turbogears/mysite/apache/
turbogears.wsgi
</VirtualHost>
In other words, create a single daemon process and delegate the TG
application to run in main interpreter in that process via directives
in Directory container where TG WSGI script file is saved.
Different virtual hosts can then mount the WSGI script file at
different mount points and all requests will go to single TG app in
the single daemon process.
As mentioned above, this depends on SCRIPT_NAME being honoured for the
mount point. Any URL construction should also honour that and the
server name, protocol etc as described in WSGI PEP at:
http://www.python.org/dev/peps/pep-0333/#url-reconstruction
The question therefore is whether TG has been updated to be a well
behaved WSGI application yet as doing what is required is certainly
straight forward using mod_wsgi if it were. Based on documentation in:
http://code.google.com/p/modwsgi/wiki/IntegrationWithTurboGears
for TG 1.X it doesn't however honour SCRIPT_NAME, but has TG 2.0 fixed
this so it is?
Graham