mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-02-15 17:05:47 -05:00
Remove static url hash middleware since we now generate named symlinks.
This commit is contained in:
@@ -83,25 +83,6 @@ def error_mapper(code, message, environ, global_conf=None, **kw):
|
||||
url = '/error/document/?%s' % (urllib.urlencode(d))
|
||||
return url
|
||||
|
||||
class StaticURLHashMiddleware(URLParser):
|
||||
"""Middleware for handling uniquely hashed static files.
|
||||
|
||||
Filenames are matched against the g.static_names mapping, which is loaded
|
||||
from names.json in the static dir. If a valid unique static filename is
|
||||
requested, the hash is stripped from the filename before the request is
|
||||
passed through to the StaticURLParser ``app``."""
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
g = config['pylons.g']
|
||||
path_info = environ.get('PATH_INFO', '')
|
||||
if path_info.startswith(g.static_path):
|
||||
dirname, filename = os.path.split(path_info)
|
||||
if filename in g.static_names_rev:
|
||||
environ['PATH_INFO'] = os.path.join(dirname, g.static_names_rev[filename])
|
||||
return self.app(environ, start_response)
|
||||
|
||||
class DebugMiddleware(object):
|
||||
def __init__(self, app, keyword):
|
||||
self.app = app
|
||||
@@ -617,7 +598,6 @@ def make_app(global_conf, full_stack=True, **app_conf):
|
||||
# Static files
|
||||
javascripts_app = StaticJavascripts()
|
||||
static_app = StaticURLParser(config['pylons.paths']['static_files'])
|
||||
#static_app = StaticURLHashMiddleware(static_app)
|
||||
app = Cascade([static_app, javascripts_app, app])
|
||||
|
||||
app = make_gzip_middleware(app, app_conf)
|
||||
|
||||
@@ -285,9 +285,6 @@ class Globals(object):
|
||||
if os.path.exists(names_file_path):
|
||||
with open(names_file_path) as handle:
|
||||
self.static_names = json.load(handle)
|
||||
# Generate a reverse mapping dictionary so that we can check
|
||||
# unique filenames in StaticURLHashMiddleware
|
||||
self.static_names_rev = dict((v, k) for k, v in self.static_names.iteritems())
|
||||
else:
|
||||
self.static_names = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user