Ticket #1919 (closed enhancement: fixed)
TG should use SCRIPT_NAME in addition to server.webpath
|Reported by:||chrisz||Owned by:||anonymous|
When put behind mod_wsgi, the TurboGears application can and should actually find out its mount point by looking at the SCRIPT_NAME CGI environment variable; there is no need to hardcode this in the server.webpath setting in this case.
Even better, if TG would care about SCRIPT_NAME, it would be possible to use different mountpoints for the same application, depending on the virtual host. For instance, the same application could be accessible as www.mycomany.com/appname/ or as appname.mycomany.com. When using server.webpath, only one fixed web path is possible.
So my suggestion is to evaluate SCRIPT_NAME and use this in addition to server.webpath.
This would also solve the problem mentioned in the mod_wsgi documentation under Integration With TurboGears:
"If you need to host the TurboGears application at a mount point other than the root of the web server, the mount point will have to be defined in the script file as the 'server.webpath' configuration option. A wrapper for the CherryPy? WSGI application entry point will also need to be used to explicitly set the 'SCRIPT_NAME' variable to an empty string. Both these changes are required as TurboGears is not a truly WSGI compliant application and does not honour the 'SCRIPT_NAME' variable passed in the WSGI application environment."
See also the discussion thread TurboGears apps with multiple web paths.
I have attached a patch against TG 1.0 (since I'm using 1.0 for my productive apps).