Skip to content

Commit 7f77264

Browse files
committed
Change the cache key construction to deal with query arguments containing spaces. Fixes 500 errors which would otherwise occur.
- Legacy-Id: 12035
1 parent 507e9fe commit 7f77264

20 files changed

Lines changed: 37 additions & 23 deletions

File tree

changelog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ietfdb (6.34.0) ietf; urgency=high
1+
ietfdb (6.34.0) ietf; urgency=medium
22

33
**New proceedings pages**
44

ietf/api/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22
import six
33
import datetime
4+
from urllib import urlencode
45

56
from django.conf import settings
67
from django.http import HttpResponse
@@ -21,6 +22,19 @@
2122

2223
_api_list = []
2324

25+
class ModelResource(tastypie.resources.ModelResource):
26+
def generate_cache_key(self, *args, **kwargs):
27+
"""
28+
Creates a unique-enough cache key.
29+
30+
This is based off the current api_name/resource_name/args/kwargs.
31+
"""
32+
#smooshed = ["%s=%s" % (key, value) for key, value in kwargs.items()]
33+
smooshed = urlencode(kwargs)
34+
35+
# Use a list plus a ``.join()`` because it's faster than concatenation.
36+
return "%s:%s:%s:%s" % (self._meta.api_name, self._meta.resource_name, ':'.join(args), ':'.join(sorted(smooshed)))
37+
2438
class Serializer(BaseSerializer):
2539
def to_html(self, data, options=None):
2640
"""

ietf/community/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Autogenerated by the mkresources management command 2014-11-13 23:53
2-
from tastypie.resources import ModelResource
2+
from ietf.api import ModelResource
33
from tastypie.fields import ToOneField, ToManyField
44
from tastypie.constants import ALL, ALL_WITH_RELATIONS
55
from tastypie.cache import SimpleCache

ietf/dbtemplate/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Autogenerated by the mkresources management command 2014-11-13 23:53
2-
from tastypie.resources import ModelResource
2+
from ietf.api import ModelResource
33
from tastypie.fields import ToOneField
44
from tastypie.constants import ALL, ALL_WITH_RELATIONS
55
from tastypie.cache import SimpleCache

ietf/doc/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Autogenerated by the makeresources management command 2015-10-19 12:29 PDT
2-
from tastypie.resources import ModelResource
2+
from ietf.api import ModelResource
33
from ietf.api import ToOneField
44
from tastypie.fields import ToManyField, CharField
55
from tastypie.constants import ALL, ALL_WITH_RELATIONS # pyflakes:ignore

ietf/group/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Autogenerated by the mkresources management command 2014-11-13 23:15
2-
from tastypie.resources import ModelResource
2+
from ietf.api import ModelResource
33
from ietf.api import ToOneField
44
from tastypie.fields import ToManyField
55
from tastypie.constants import ALL, ALL_WITH_RELATIONS

ietf/iesg/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Autogenerated by the mkresources management command 2014-11-13 23:53
2-
from tastypie.resources import ModelResource
2+
from ietf.api import ModelResource
33
from tastypie.constants import ALL
44
from tastypie.cache import SimpleCache
55

ietf/ipr/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Autogenerated by the mkresources management command 2015-03-21 14:05 PDT
2-
from tastypie.resources import ModelResource
2+
from ietf.api import ModelResource
33
from ietf.api import ToOneField
44
from tastypie.fields import ToManyField # pyflakes:ignore
55
from tastypie.constants import ALL, ALL_WITH_RELATIONS # pyflakes:ignore

ietf/liaisons/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Autogenerated by the makeresources management command 2015-10-11 13:15 PDT
2-
from tastypie.resources import ModelResource
2+
from ietf.api import ModelResource
33
from ietf.api import ToOneField
44
from tastypie.fields import ToManyField # pyflakes:ignore
55
from tastypie.constants import ALL, ALL_WITH_RELATIONS # pyflakes:ignore

ietf/mailinglists/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright The IETF Trust 2016, All Rights Reserved
22
# Autogenerated by the makeresources management command 2016-06-12 12:29 PDT
3-
from tastypie.resources import ModelResource
3+
from ietf.api import ModelResource
44
from tastypie.fields import ToManyField # pyflakes:ignore
55
from tastypie.constants import ALL, ALL_WITH_RELATIONS # pyflakes:ignore
66
from tastypie.cache import SimpleCache

0 commit comments

Comments
 (0)