Change the cache key construction to deal with query arguments containing spaces. Fixes 500 errors which would otherwise occur.

- Legacy-Id: 12035
This commit is contained in:
Henrik Levkowetz 2016-09-25 13:53:22 +00:00
parent 507e9fe6bb
commit 7f772641d4
20 changed files with 37 additions and 23 deletions

View file

@ -1,4 +1,4 @@
ietfdb (6.34.0) ietf; urgency=high
ietfdb (6.34.0) ietf; urgency=medium
**New proceedings pages**

View file

@ -1,6 +1,7 @@
import re
import six
import datetime
from urllib import urlencode
from django.conf import settings
from django.http import HttpResponse
@ -21,6 +22,19 @@ import debug # pyflakes:ignore
_api_list = []
class ModelResource(tastypie.resources.ModelResource):
def generate_cache_key(self, *args, **kwargs):
"""
Creates a unique-enough cache key.
This is based off the current api_name/resource_name/args/kwargs.
"""
#smooshed = ["%s=%s" % (key, value) for key, value in kwargs.items()]
smooshed = urlencode(kwargs)
# Use a list plus a ``.join()`` because it's faster than concatenation.
return "%s:%s:%s:%s" % (self._meta.api_name, self._meta.resource_name, ':'.join(args), ':'.join(sorted(smooshed)))
class Serializer(BaseSerializer):
def to_html(self, data, options=None):
"""

View file

@ -1,5 +1,5 @@
# Autogenerated by the mkresources management command 2014-11-13 23:53
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from tastypie.fields import ToOneField, ToManyField
from tastypie.constants import ALL, ALL_WITH_RELATIONS
from tastypie.cache import SimpleCache

View file

@ -1,5 +1,5 @@
# Autogenerated by the mkresources management command 2014-11-13 23:53
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from tastypie.fields import ToOneField
from tastypie.constants import ALL, ALL_WITH_RELATIONS
from tastypie.cache import SimpleCache

View file

@ -1,5 +1,5 @@
# Autogenerated by the makeresources management command 2015-10-19 12:29 PDT
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from ietf.api import ToOneField
from tastypie.fields import ToManyField, CharField
from tastypie.constants import ALL, ALL_WITH_RELATIONS # pyflakes:ignore

View file

@ -1,5 +1,5 @@
# Autogenerated by the mkresources management command 2014-11-13 23:15
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from ietf.api import ToOneField
from tastypie.fields import ToManyField
from tastypie.constants import ALL, ALL_WITH_RELATIONS

View file

@ -1,5 +1,5 @@
# Autogenerated by the mkresources management command 2014-11-13 23:53
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from tastypie.constants import ALL
from tastypie.cache import SimpleCache

View file

@ -1,5 +1,5 @@
# Autogenerated by the mkresources management command 2015-03-21 14:05 PDT
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from ietf.api import ToOneField
from tastypie.fields import ToManyField # pyflakes:ignore
from tastypie.constants import ALL, ALL_WITH_RELATIONS # pyflakes:ignore

View file

@ -1,5 +1,5 @@
# Autogenerated by the makeresources management command 2015-10-11 13:15 PDT
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from ietf.api import ToOneField
from tastypie.fields import ToManyField # pyflakes:ignore
from tastypie.constants import ALL, ALL_WITH_RELATIONS # pyflakes:ignore

View file

@ -1,6 +1,6 @@
# Copyright The IETF Trust 2016, All Rights Reserved
# Autogenerated by the makeresources management command 2016-06-12 12:29 PDT
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from tastypie.fields import ToManyField # pyflakes:ignore
from tastypie.constants import ALL, ALL_WITH_RELATIONS # pyflakes:ignore
from tastypie.cache import SimpleCache

View file

@ -1,5 +1,5 @@
# Autogenerated by the makeresources management command 2015-08-06 11:00 PDT
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from ietf.api import ToOneField # pyflakes:ignore
from tastypie.fields import ToManyField # pyflakes:ignore
from tastypie.constants import ALL, ALL_WITH_RELATIONS # pyflakes:ignore

View file

@ -1,5 +1,5 @@
# Autogenerated by the mkresources management command 2014-11-13 23:15
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from ietf.api import ToOneField
from tastypie.fields import ToManyField, DateTimeField
from tastypie.constants import ALL, ALL_WITH_RELATIONS

View file

@ -1,5 +1,5 @@
# Autogenerated by the mkresources management command 2014-11-13 23:53
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from ietf.api import ToOneField
from tastypie.fields import ToManyField
from tastypie.constants import ALL, ALL_WITH_RELATIONS

View file

@ -1,5 +1,5 @@
# Autogenerated by the makeresources management command 2015-08-27 11:01 PDT
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from ietf.api import ToOneField # pyflakes:ignore
from tastypie.fields import ToManyField # pyflakes:ignore
from tastypie.constants import ALL, ALL_WITH_RELATIONS # pyflakes:ignore

View file

@ -1,5 +1,5 @@
# Autogenerated by the mkresources management command 2014-11-13 23:53
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from ietf.api import ToOneField
from tastypie.fields import ToManyField
from tastypie.constants import ALL, ALL_WITH_RELATIONS

View file

@ -1,5 +1,5 @@
# Autogenerated by the mkresources management command 2014-11-13 23:53
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from tastypie.fields import ToOneField
from tastypie.constants import ALL, ALL_WITH_RELATIONS
from tastypie.cache import SimpleCache

View file

@ -1,5 +1,5 @@
# Autogenerated by the mkresources management command 2014-11-13 23:53
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from tastypie.fields import ToOneField
from tastypie.constants import ALL, ALL_WITH_RELATIONS
from tastypie.cache import SimpleCache

View file

@ -716,11 +716,11 @@ if SERVER_MODE != 'production':
# stomp out the cached template loader, it's annoying
TEMPLATE_LOADERS = tuple(l for e in TEMPLATE_LOADERS for l in (e[1] if isinstance(e, tuple) and "cached.Loader" in e[0] else (e,)))
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
# CACHES = {
# 'default': {
# 'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
# }
# }
SESSION_ENGINE = "django.contrib.sessions.backends.db"
if 'SECRET_KEY' not in locals():

View file

@ -1,5 +1,5 @@
# Autogenerated by the mkresources management command 2014-11-13 23:53
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from tastypie.fields import ToOneField
from tastypie.constants import ALL, ALL_WITH_RELATIONS
from tastypie.cache import SimpleCache

View file

@ -1,5 +1,5 @@
# Autogenerated by the mkresources management command 2014-11-13 05:39
from tastypie.resources import ModelResource
from ietf.api import ModelResource
from tastypie.fields import CharField
from tastypie.constants import ALL
from tastypie.cache import SimpleCache