r7244 - in branches/1.5/turbogears: . qstemplates/quickstart

1 view
Skip to first unread message

svn-c...@turbogears.org

unread,
Mar 8, 2011, 7:57:01 AM3/8/11
to turbogear...@googlegroups.com
Author: chrisz
Date: Tue Mar 8 06:56:58 2011
New Revision: 7244
URL: http://trac.turbogears.org/changeset/7244

Log:
Better integration of the server.webpath setting with CherryPy.
E.g. the trainling slash tool will work properly now (#2550)

Modified:
branches/1.5/turbogears/controllers.py
branches/1.5/turbogears/dispatchers.py
branches/1.5/turbogears/qstemplates/quickstart/dev.cfg_tmpl
branches/1.5/turbogears/startup.py

Modified: branches/1.5/turbogears/controllers.py
==============================================================================
--- branches/1.5/turbogears/controllers.py Tue Mar 8 05:09:05 2011 (r7243)
+++ branches/1.5/turbogears/controllers.py Tue Mar 8 06:56:58 2011 (r7244)
@@ -587,9 +587,15 @@
if not isinstance(tgpath, basestring):
tgpath = '/'.join(list(tgpath))
if tgpath.startswith('/'):
+ webpath = config.server.get('server.webpath', '')
if tg_util.request_available():
tgpath = cp_url(tgpath, relative='server')
- tgpath = config.server.get('server.webpath', '') + tgpath
+ if not request.script_name.startswith(webpath):
+ # the virtual path dispatcher is not running
+ tgpath = webpath + tgpath
+ elif webpath:
+ # the server is not running
+ tgpath = webpath + tgpath
if tgparams is None:
tgparams = kw
else:

Modified: branches/1.5/turbogears/dispatchers.py
==============================================================================
--- branches/1.5/turbogears/dispatchers.py Tue Mar 8 05:09:05 2011 (r7243)
+++ branches/1.5/turbogears/dispatchers.py Tue Mar 8 06:56:58 2011 (r7244)
@@ -25,16 +25,17 @@
def __call__(self, path_info):
"""Determine the relevant path info by stripping off prefixes.

- Strips webpath and SCRIPT_NAME from request.path_info.
+ Strips webpath and request.script_name from request.path_info.

"""
webpath = self.webpath
try:
- webpath += request.wsgi_environ['SCRIPT_NAME'].rstrip('/')
- except (AttributeError, KeyError):
+ webpath += request.script_name.rstrip('/')
+ except AttributeError:
pass
if webpath:
if path_info.startswith(webpath + '/'):
+ request.script_name = webpath
request.path_info = path_info = path_info[len(webpath):]
else:
# check for webpath only if not forwarded

Modified: branches/1.5/turbogears/qstemplates/quickstart/dev.cfg_tmpl
==============================================================================
--- branches/1.5/turbogears/qstemplates/quickstart/dev.cfg_tmpl Tue Mar 8 05:09:05 2011 (r7243)
+++ branches/1.5/turbogears/qstemplates/quickstart/dev.cfg_tmpl Tue Mar 8 06:56:58 2011 (r7244)
@@ -51,6 +51,9 @@
# Auto-Reload after code modification
engine.autoreload.on = True

+# During development, missing slashes in links should not go unnoticed
+tools.trailing_slash.on = False
+
# Set to True if you'd like to abort execution if a controller gets an
# unexpected parameter. False by default
tg.strict_parameters = True

Modified: branches/1.5/turbogears/startup.py
==============================================================================
--- branches/1.5/turbogears/startup.py Tue Mar 8 05:09:05 2011 (r7243)
+++ branches/1.5/turbogears/startup.py Tue Mar 8 06:56:58 2011 (r7244)
@@ -161,13 +161,13 @@
hooks.attach('on_end_resource', database.EndTransactions)
# The NestedVariablesHook needs to happen after cherrypy.tools.decode
# so that request params are properly decoded before it runs
- hooks.attach('before_handler', NestedVariablesHook, priority=70)
+ hooks.attach('before_handler', NestedVariablesHook, priority=64)
if config.get('visit.on', False):
# The VisitTool needs to happen after cherrypy.tools.decode
# so that request params are properly decoded before it runs,
# but it must run before the NestedVariablesHook to work properly
cherrypy.tools.visit = cherrypy.Tool(
- 'before_handler', VisitTool(), priority=60)
+ 'before_handler', VisitTool(), priority=62)

# Register server with Bonjour framework
bonjoursetting = config.get('tg.bonjour', None)

Reply all
Reply to author
Forward
0 new messages