Require explicit tagging on views taking query parameters

Require each view to declare which query parameters it wants, and filter
out any other parameters.

We have very few views that actually take query parameters, and random
additional query patterns will have no effect on the view. However, they
will break frontend caching (in making them look like different pages).

This will be extended into an implementation in the caching frontends as
well, btu it's needed in the backend to ensure that local testing will
have tbe same effect as the caches.
This commit is contained in:
Magnus Hagander
2021-02-22 10:43:59 +01:00
parent b23309c95d
commit 0724c08e40
4 changed files with 45 additions and 2 deletions

View File

@ -24,6 +24,17 @@ def cache(days=0, hours=0, minutes=0, seconds=0):
return _cache
def queryparams(*args):
"""
Allow specified query parameters when calling function.
NOTE! Must be the "outermost" decorator!!!
"""
def _queryparams(fn):
fn.queryparams = args
return fn
return _queryparams
def allow_frames(fn):
def _allow_frames(request, *_args, **_kwargs):
resp = fn(request, *_args, **_kwargs)