Add support for automatic template based xkey
commitdcd98cf6fe978e25021b40eec9cad097a185a752
authorMagnus Hagander <magnus@hagander.net>
Thu, 26 Apr 2018 18:21:01 +0000 (26 20:21 +0200)
committerMagnus Hagander <magnus@hagander.net>
Fri, 29 Jun 2018 16:01:35 +0000 (29 18:01 +0200)
tree3dc89f3283b40c1ff6a60eee9461070597d37c5c
parentb7bed6dece8904171c967ea2a1f28b22fcf8b3c8
Add support for automatic template based xkey

This adds an xkey header to all outgoing requests with the hash of the
name of all templates loaded. In the future we will be able to use this
to purge "all pages that included a specific template", regardless of
where in the hierarchy it was loaded.

Do this by faking a template loader that never finds anything -- but it
will record the path of the template that it tried to load, and then
leave it to another template loader to actually load it. Store this in
thread local storage (it's a bit ugly, but it's the only thing Django
supports for storing things at the request level from a template
loader), and fetch it from the middleware.
pgweb/settings.py
pgweb/util/middleware.py
pgweb/util/templateloader.py [new file with mode: 0644]