From d50d977dc3e5701af9c4a0fea024aab4c056b3b7 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Sun, 15 Oct 2017 20:42:45 +0200 Subject: [PATCH] caching of static views configurable --- development.ini | 3 +++ ordr2/__init__.py | 1 + ordr2/views/__init__.py | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/development.ini b/development.ini index edc4eab..6ea25ea 100644 --- a/development.ini +++ b/development.ini @@ -16,6 +16,9 @@ pyramid.includes = sqlalchemy.url = sqlite:///%(here)s/ordr2.sqlite +auth.secret = 'change me' +static_views.cache_max_age = 0 + # By default, the toolbar only appears for clients from IP addresses # '127.0.0.1' and '::1'. # debugtoolbar.hosts = 127.0.0.1 ::1 diff --git a/ordr2/__init__.py b/ordr2/__init__.py index 72d5dab..141cf69 100644 --- a/ordr2/__init__.py +++ b/ordr2/__init__.py @@ -16,6 +16,7 @@ def main(global_config, **settings): config.include('.models') config.include('.resources') config.include('.security') + config.include('ordr2.views') config.scan() diff --git a/ordr2/views/__init__.py b/ordr2/views/__init__.py index fe727e6..e056593 100644 --- a/ordr2/views/__init__.py +++ b/ordr2/views/__init__.py @@ -8,4 +8,7 @@ def includeme(config): Activate this setup using ``config.include('ordr2.views')``. ''' - config.add_static_view('static', 'ordr2:static', cache_max_age=3600) + settings = config.get_settings() + age = int(settings.get('static_views.cache_max_age', 3600)) + + config.add_static_view('static', 'ordr2:static', cache_max_age=age)