equal
deleted
inserted
replaced
9 from django.http.response import Http404 |
9 from django.http.response import Http404 |
10 from django.shortcuts import get_object_or_404 |
10 from django.shortcuts import get_object_or_404 |
11 from django.utils.encoding import smart_str |
11 from django.utils.encoding import smart_str |
12 from renkanmanager.models import Renkan |
12 from renkanmanager.models import Renkan |
13 import math |
13 import math |
14 import md5 |
14 import hashlib |
15 import re |
15 import re |
16 import uuid |
16 import uuid |
17 |
17 |
18 import logging |
18 import logging |
19 logger = logging.getLogger(__name__) |
19 logger = logging.getLogger(__name__) |
21 |
21 |
22 def fix_cache_key(key): |
22 def fix_cache_key(key): |
23 cache_key = re.sub(r'\s+', '-', key) |
23 cache_key = re.sub(r'\s+', '-', key) |
24 cache_key = smart_str(cache_key) |
24 cache_key = smart_str(cache_key) |
25 if len(cache_key) > (250-(2+len(cache.key_prefix)+len(str(cache.version)))-33): |
25 if len(cache_key) > (250-(2+len(cache.key_prefix)+len(str(cache.version)))-33): |
26 cache_key = cache_key[:(250-(2+len(cache.key_prefix)+len(str(cache.version)))-33)] + '-' + md5.new(cache_key).hexdigest() |
26 cache_key = cache_key[:(250-(2+len(cache.key_prefix)+len(str(cache.version)))-33)] + '-' + hashlib.md5(cache_key).hexdigest() |
27 return cache_key |
27 return cache_key |
28 |
28 |
29 |
29 |
30 |
30 |
31 class NodePlacer(): |
31 class NodePlacer(): |