Browse Source

cache_max_age for static views configurable in ini file

php2python
Holger Frey 7 years ago
parent
commit
15de311063
  1. 1
      development.ini
  2. 7
      ordr2/views/__init__.py

1
development.ini

@ -25,6 +25,7 @@ sqlalchemy.url = sqlite:///%(here)s/ordr2.sqlite @@ -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

7
ordr2/views/__init__.py

@ -14,6 +14,9 @@ def includeme(config): @@ -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)