Browse Source

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
changes/36/550636/1
Monty Taylor 4 years ago
parent
commit
666c7b7c44
No known key found for this signature in database GPG Key ID: 7BAE94BC7141A594
  1. 5
      zuul/web/handler.py

5
zuul/web/handler.py

@ -17,8 +17,6 @@ import os
from aiohttp import web
STATIC_DIR = os.path.join(os.path.dirname(__file__), 'static')
class BaseWebHandler(object, metaclass=abc.ABCMeta):
@ -49,12 +47,13 @@ class StaticHandler(BaseWebHandler):
def __init__(self, zuul_web, path, file_path=None):
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]
async def handleRequest(self, request):
"""Process a web request."""
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:
headers['Cache-Control'] = "public, max-age=%d" % \
self.zuul_web.static_cache_expiry

Loading…
Cancel
Save