From: Ben Darnell Date: Mon, 3 Jan 2011 21:45:52 +0000 (-0800) Subject: Use absolute paths in RequestHandler._static_hashes to allow for different X-Git-Tag: v1.2.0~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=daf9669eb03f8d4bd05a88385655cd413e1faedb;p=thirdparty%2Ftornado.git Use absolute paths in RequestHandler._static_hashes to allow for different static_paths. --- diff --git a/tornado/web.py b/tornado/web.py index cb15f12a7..ceb43e24b 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -763,20 +763,21 @@ class RequestHandler(object): if not hasattr(RequestHandler, "_static_hashes"): RequestHandler._static_hashes = {} hashes = RequestHandler._static_hashes - if path not in hashes: + abs_path = os.path.join(self.application.settings["static_path"], + path) + if abs_path not in hashes: try: - f = open(os.path.join( - self.application.settings["static_path"], path)) - hashes[path] = hashlib.md5(f.read()).hexdigest() + f = open(abs_path) + hashes[abs_path] = hashlib.md5(f.read()).hexdigest() f.close() except: logging.error("Could not open static file %r", path) - hashes[path] = None + hashes[abs_path] = None base = self.request.protocol + "://" + self.request.host \ if getattr(self, "include_host", False) else "" static_url_prefix = self.settings.get('static_url_prefix', '/static/') - if hashes.get(path): - return base + static_url_prefix + path + "?v=" + hashes[path][:5] + if hashes.get(abs_path): + return base + static_url_prefix + path + "?v=" + hashes[abs_path][:5] else: return base + static_url_prefix + path