Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1919 (closed enhancement: fixed)

Opened 9 years ago

Last modified 9 years ago

TG should use SCRIPT_NAME in addition to server.webpath

Reported by: chrisz Owned by: 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 Download (4.2 KB) - added by chrisz 9 years ago.
Patch to make TG 1.0 use SCRIPT_NAME in addition to server.webpath

Change History

Changed 9 years ago by chrisz

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

comment:1 Changed 9 years ago 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.

comment:2 Changed 9 years ago 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.

Note: See TracTickets for help on using tickets.