Actually honor the static_path config value
The puppet in puppet-zuul puts the static files somewhere that isn't inside the python path and sets static_path to point to it. Unfortunately, the refactor to split some handler base classes into the handlers file wound up with StaticHandler just using the STATIC_DIR default. Instead, let's use the value set on the zuul_web instance, since that will either be the config value or STATIC_DIR as a fallback. Change-Id: Ie512ceb8c9348749c9ad40ee4057950bbb2766ea
This commit is contained in:
parent
d54d1a1b60
commit
666c7b7c44
|
@ -17,8 +17,6 @@ import os
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
|
||||||
STATIC_DIR = os.path.join(os.path.dirname(__file__), 'static')
|
|
||||||
|
|
||||||
|
|
||||||
class BaseWebHandler(object, metaclass=abc.ABCMeta):
|
class BaseWebHandler(object, metaclass=abc.ABCMeta):
|
||||||
|
|
||||||
|
@ -49,12 +47,13 @@ class StaticHandler(BaseWebHandler):
|
||||||
|
|
||||||
def __init__(self, zuul_web, path, file_path=None):
|
def __init__(self, zuul_web, path, file_path=None):
|
||||||
super(StaticHandler, self).__init__(None, zuul_web, 'GET', path)
|
super(StaticHandler, self).__init__(None, zuul_web, 'GET', path)
|
||||||
|
self.static_path = zuul_web.static_path
|
||||||
self.file_path = file_path or path.split('/')[-1]
|
self.file_path = file_path or path.split('/')[-1]
|
||||||
|
|
||||||
async def handleRequest(self, request):
|
async def handleRequest(self, request):
|
||||||
"""Process a web request."""
|
"""Process a web request."""
|
||||||
headers = {}
|
headers = {}
|
||||||
fp = os.path.join(STATIC_DIR, self.file_path)
|
fp = os.path.join(self.static_path, self.file_path)
|
||||||
if self.zuul_web.static_cache_expiry:
|
if self.zuul_web.static_cache_expiry:
|
||||||
headers['Cache-Control'] = "public, max-age=%d" % \
|
headers['Cache-Control'] = "public, max-age=%d" % \
|
||||||
self.zuul_web.static_cache_expiry
|
self.zuul_web.static_cache_expiry
|
||||||
|
|
Loading…
Reference in New Issue