Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.
| File wsgi.patch,
4.2 KB
(added by chrisz, 4 years ago) |
|
Patch to make TG 1.0 use SCRIPT_NAME in addition to server.webpath
|
-
|
|
|
|
| 501 | 501 | """Computes URLs. |
| 502 | 502 | |
| 503 | 503 | tgpath can be a list or a string. If the path is absolute (starts |
| 504 | | with a "/"), the server.webpath and the approot of the application |
| 505 | | are prepended to the path. In order for the approot to be |
| 506 | | detected properly, the root object should extend |
| | 504 | with a "/"), the server.webpath, SCRIPT_NAME and the approot of the |
| | 505 | application are prepended to the path. In order for the approot to |
| | 506 | be detected properly, the root object should extend |
| 507 | 507 | controllers.RootController. |
| 508 | 508 | |
| 509 | 509 | Query parameters for the URL can be passed in as a dictionary in |
| … |
… |
|
| 516 | 516 | if not isinstance(tgpath, basestring): |
| 517 | 517 | tgpath = "/".join(list(tgpath)) |
| 518 | 518 | if tgpath.startswith("/"): |
| | 519 | webpath = config.get('server.webpath', '').rstrip('/') |
| 519 | 520 | if tg_util.request_available(): |
| 520 | 521 | check_app_root() |
| 521 | 522 | tgpath = request.app_root + tgpath |
| 522 | | result = config.get("server.webpath", "") + tgpath |
| 523 | | else: |
| 524 | | result = tgpath |
| | 523 | try: |
| | 524 | webpath += request.wsgi_environ['SCRIPT_NAME'].rstrip('/') |
| | 525 | except (AttributeError, KeyError): |
| | 526 | pass |
| | 527 | tgpath = webpath + tgpath |
| 525 | 528 | if tgparams is None: |
| 526 | 529 | tgparams = kw |
| 527 | 530 | else: |
| … |
… |
|
| 545 | 548 | v = v.encode("utf8") |
| 546 | 549 | args.append("%s=%s" % (k, urllib.quote(str(v)))) |
| 547 | 550 | if args: |
| 548 | | result += "?" + "&".join(args) |
| 549 | | return result |
| | 551 | tgpath += "?" + "&".join(args) |
| | 552 | return tgpath |
| 550 | 553 | |
| 551 | 554 | |
| 552 | 555 | def check_app_root(): |
-
|
|
|
|
| 78 | 78 | |
| 79 | 79 | cherrypy.lib.autoreload.reloader_thread = reloader_thread |
| 80 | 80 | |
| 81 | | webpath = "" |
| | 81 | webpath = '' |
| 82 | 82 | |
| 83 | 83 | DNS_SD_PID = None |
| 84 | 84 | |
| … |
… |
|
| 129 | 129 | maps to the root object "/". |
| 130 | 130 | """ |
| 131 | 131 | |
| | 132 | def __init__(self, webpath=''): |
| | 133 | webpath = webpath.rstrip('/') |
| | 134 | if webpath and not webpath.startswith('/'): |
| | 135 | webpath = '/' + webpath |
| | 136 | self.webpath = webpath |
| | 137 | |
| 132 | 138 | def on_start_resource(self): |
| 133 | | prefix = config.get('server.webpath', False) |
| 134 | | if prefix: |
| | 139 | webpath = self.webpath |
| | 140 | try: |
| | 141 | webpath += cherrypy.request.wsgi_environ['SCRIPT_NAME'].rstrip('/') |
| | 142 | except (AttributeError, KeyError): |
| | 143 | pass |
| | 144 | if webpath: |
| 135 | 145 | path = cherrypy.request.object_path |
| 136 | | if path == prefix: |
| | 146 | if path == webpath: |
| 137 | 147 | cherrypy.request.object_path = '/' |
| 138 | | elif path.startswith(prefix): |
| 139 | | cherrypy.request.object_path = path[len(prefix):] |
| | 148 | elif path.startswith(webpath): |
| | 149 | cherrypy.request.object_path = path[len(webpath):] |
| 140 | 150 | else: |
| 141 | 151 | raise cherrypy.NotFound(path) |
| 142 | 152 | |
| … |
… |
|
| 182 | 192 | view.load_engines() |
| 183 | 193 | view.loadBaseTemplates() |
| 184 | 194 | global webpath |
| 185 | | webpath = config.get("server.webpath", "") |
| | 195 | webpath = config.get('server.webpath', '') |
| 186 | 196 | |
| 187 | | if hasattr(cherrypy, "root") and cherrypy.root: |
| 188 | | if not hasattr(cherrypy.root, "_cp_filters"): |
| | 197 | if hasattr(cherrypy, 'root') and cherrypy.root: |
| | 198 | if not hasattr(cherrypy.root, '_cp_filters'): |
| 189 | 199 | cherrypy.root._cp_filters= [] |
| 190 | | morefilters = [EndTransactionsFilter(), |
| 191 | | NestedVariablesFilter()] |
| 192 | | if webpath: |
| 193 | | morefilters.insert(0, VirtualPathFilter()) |
| | 200 | morefilters = [EndTransactionsFilter(), NestedVariablesFilter()] |
| | 201 | morefilters.insert(0, VirtualPathFilter(webpath)) |
| 194 | 202 | cherrypy.root._cp_filters.extend(morefilters) |
| 195 | 203 | |
| 196 | | if webpath.startswith("/"): |
| 197 | | webpath = webpath[1:] |
| 198 | | if webpath and not webpath.endswith("/"): |
| 199 | | webpath = webpath + "/" |
| | 204 | webpath = webpath.lstrip('/') |
| | 205 | if webpath and not webpath.endswith('/'): |
| | 206 | webpath += '/' |
| | 207 | |
| 200 | 208 | isdev = config.get('server.environment') == 'development' |
| 201 | 209 | if not config.get("tg.new_style_logging"): |
| 202 | 210 | if config.get('server.log_to_screen'): |
Download in other formats: