Browse Source

caching of static views configurable

master
Holger Frey 7 years ago
parent
commit
d50d977dc3
  1. 3
      development.ini
  2. 1
      ordr2/__init__.py
  3. 5
      ordr2/views/__init__.py

3
development.ini

@ -16,6 +16,9 @@ pyramid.includes = @@ -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

1
ordr2/__init__.py

@ -16,6 +16,7 @@ def main(global_config, **settings): @@ -16,6 +16,7 @@ def main(global_config, **settings):
config.include('.models')
config.include('.resources')
config.include('.security')
config.include('ordr2.views')
config.scan()

5
ordr2/views/__init__.py

@ -8,4 +8,7 @@ def includeme(config): @@ -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)