0001-misc-add-a-new-statics_hash-in-context-variables-887.patch
hobo/__init__.py | ||
---|---|---|
1 |
# import the context_processors module so it gets to compute the versions hash |
|
2 |
# early on. |
|
3 |
from . import context_processors |
hobo/context_processors.py | ||
---|---|---|
3 | 3 |
import logging |
4 | 4 |
import requests |
5 | 5 |
import threading |
6 |
import os |
|
6 | 7 |
import urlparse |
7 | 8 | |
8 | 9 |
from django.conf import settings |
9 | 10 |
from django.core.cache import cache |
10 | 11 |
from django.template import Template |
11 | 12 | |
12 |
def template_vars(request): |
|
13 |
return getattr(settings, 'TEMPLATE_VARS', {}) |
|
13 |
from hobo.scrutiny.wsgi.middleware import VersionMiddleware |
|
14 | 14 | |
15 | 15 |
logger = logging.getLogger('hobo') |
16 | 16 | |
17 | 17 |
CACHE_REFRESH_TIMEOUT = 300 |
18 |
VERSIONS = VersionMiddleware.get_packages_version() |
|
19 | ||
20 | ||
21 |
def template_vars(request): |
|
22 |
statics_hash = hashlib.md5(repr(sorted(VERSIONS.items()))) |
|
23 |
try: |
|
24 |
statics_hash.update(str(os.stat('/var/lib/publik/theme-counter').st_atime)) |
|
25 |
except OSError: |
|
26 |
pass |
|
27 |
template_vars = getattr(settings, 'TEMPLATE_VARS', {}) |
|
28 |
template_vars.update({'statics_hash': statics_hash.hexdigest()}) |
|
29 |
return template_vars |
|
18 | 30 | |
19 | 31 |
class RemoteTemplate(object): |
20 | 32 |
def __init__(self, source): |
21 |
- |