from django.db import models, IntegrityError, connection, transaction
from django.utils.http import urlquote as django_urlquote
from django.utils.html import strip_tags
+from django.conf import settings as django_settings
from django.core.urlresolvers import reverse
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
pk = [v for (k,v) in querydict.items() if k in ('pk', 'pk__exact', 'id', 'id__exact'
) or k.endswith('_ptr__pk') or k.endswith('_ptr__id')][0]
- return cls._generate_cache_key(pk)
+ cache_key = cls._generate_cache_key(pk)
+
+ if len(cache_key) > django_settings.CACHE_MAX_KEY_LENGTH:
+ cache_key = cache_key[:django_settings.CACHE_MAX_KEY_LENGTH]
+
+ return cache_key
except:
return None
import datetime
from base import *
+from django.conf import settings as django_settings
+from django.core.cache.backends.base import BaseCache
from django.utils.translation import ugettext as _
from django.utils.encoding import smart_unicode, force_unicode
@classmethod
def infer_cache_key(cls, querydict):
if 'name' in querydict:
- return cls._generate_cache_key(cls.safe_cache_name(querydict['name']))
+ cache_key = cls._generate_cache_key(cls.safe_cache_name(querydict['name']))
+
+ if len(cache_key) > django_settings.CACHE_MAX_KEY_LENGTH:
+ cache_key = cache_key[:django_settings.CACHE_MAX_KEY_LENGTH]
+
+ return cache_key
return None
from base import *
from utils import PickledObjectField
+from django.conf import settings as django_settings
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User as DjangoUser, AnonymousUser as DjangoAnonymousUser
@classmethod
def infer_cache_key(cls, querydict):
if 'user' in querydict and 'key' in querydict:
- return cls._generate_cache_key("%s:%s" % (querydict['user'].id, querydict['key']))
+ cache_key = cls._generate_cache_key("%s:%s" % (querydict['user'].id, querydict['key']))
+ if len(cache_key) > django_settings.CACHE_MAX_KEY_LENGTH:
+ cache_key = cache_key[:django_settings.CACHE_MAX_KEY_LENGTH]
+ return cache_key
return None
ADMIN_MEDIA_PREFIX = '/admin_media/'
SECRET_KEY = '$oo^&_m&qwbib=(_4m_n*zn-d=g#s0he5fx9xonnym#8p6yigm'
+CACHE_MAX_KEY_LENGTH = 235
+
TEMPLATE_LOADERS = [
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',