Ticket #1919 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

TG should use SCRIPT_NAME in addition to server.webpath

Reported by: chrisz Assigned to: anonymous
Priority: normal Milestone: 1.5
Component: TurboGears Version: 1.0.5
Severity: normal Keywords: wsgi webpath
Cc:

Description

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).

Attachments

wsgi.patch (4.2 kB) - added by chrisz on 08/01/08 12:52:00.
Patch to make TG 1.0 use SCRIPT_NAME in addition to server.webpath

Change History

08/01/08 12:52:00 changed by chrisz

  • attachment wsgi.patch added.

Patch to make TG 1.0 use SCRIPT_NAME in addition to server.webpath

08/13/08 17:55:31 changed by chrisz

  • version changed from 1.0.4.4 to 1.0.5.
  • milestone changed from 1.0.x bugfix to 1.5.

Fixed in r5145 for TG 1.0 and TG 1.1.

Not yet fixed in TG 1.5 since it is using CherryPy? 3 and I haven't checked whether this is still necessary and applicable there. So leaving this open for now.

08/19/08 14:43:59 changed by kskuhlman

  • status changed from new to closed.
  • resolution set to fixed.

Created a new ticket, #1946, for TG 1.5 since it's a new issue specific to what I did on that branch.