From 15de31106390ace64cddbc48cba3b0d22b284e3f Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Thu, 28 Sep 2017 12:43:35 +0200 Subject: [PATCH] cache_max_age for static views configurable in ini file --- development.ini | 1 + ordr2/views/__init__.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/development.ini b/development.ini index 406c35e..c0ea66d 100644 --- a/development.ini +++ b/development.ini @@ -25,6 +25,7 @@ sqlalchemy.url = sqlite:///%(here)s/ordr2.sqlite auth.secret = 'Change Me 1' session.secret = 'Change Me 2' session.auto_csrf = true +static_views.cache_max_age = 0 ### # wsgi server configuration diff --git a/ordr2/views/__init__.py b/ordr2/views/__init__.py index c4da379..e903c81 100644 --- a/ordr2/views/__init__.py +++ b/ordr2/views/__init__.py @@ -14,6 +14,9 @@ def includeme(config): ''' adding request helpers and static views ''' config.add_request_method(flash, 'flash') - config.add_static_view('static', 'ordr2:static', cache_max_age=3600) - config.add_static_view('deform', 'deform:static') + 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) + config.add_static_view('deform', 'deform:static', cache_max_age=age)