Commit c20a3223 authored by Tim Graham's avatar Tim Graham

Use python_2_unicode_compatible from Django rather than compat

parent 8433d02e
...@@ -26,19 +26,3 @@ if django.VERSION[:2] >= (1, 6): ...@@ -26,19 +26,3 @@ if django.VERSION[:2] >= (1, 6):
DEFAULT_TIMEOUT = DJANGO_DEFAULT_TIMEOUT DEFAULT_TIMEOUT = DJANGO_DEFAULT_TIMEOUT
else: else:
DEFAULT_TIMEOUT = None DEFAULT_TIMEOUT = None
def python_2_unicode_compatible(klass):
"""
A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
Backported from Django 1.5+.
"""
if not PY3:
klass.__unicode__ = klass.__str__
klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
return klass
...@@ -2,11 +2,10 @@ import importlib ...@@ -2,11 +2,10 @@ import importlib
import warnings import warnings
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.utils.encoding import python_2_unicode_compatible
from redis.connection import SSLConnection from redis.connection import SSLConnection
from redis_cache.compat import ( from redis_cache.compat import smart_text, parse_qs, urlparse
smart_text, python_2_unicode_compatible, parse_qs, urlparse
)
try: try:
basestring basestring
...@@ -26,13 +25,13 @@ class CacheKey(object): ...@@ -26,13 +25,13 @@ class CacheKey(object):
def __eq__(self, other): def __eq__(self, other):
return self._versioned_key == other return self._versioned_key == other
def __unicode__(self): def __str__(self):
return smart_text(self._versioned_key) return smart_text(self._versioned_key)
def __hash__(self): def __hash__(self):
return hash(self._versioned_key) return hash(self._versioned_key)
__repr__ = __str__ = __unicode__ __repr__ = __str__
def get_servers(location): def get_servers(location):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment