Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
Django-Redis-Cache
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shared
Django-Redis-Cache
Commits
59caf9cd
Commit
59caf9cd
authored
Jun 12, 2013
by
Carl Meyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
smart_unicode does not exist with Python 3 / Django 1.5.
parent
28f14177
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
cache.py
redis_cache/cache.py
+4
-4
compat.py
redis_cache/compat.py
+8
-0
No files found.
redis_cache/cache.py
View file @
59caf9cd
from
django.core.cache.backends.base
import
BaseCache
,
InvalidCacheBackendError
from
django.core.cache.backends.base
import
BaseCache
,
InvalidCacheBackendError
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.exceptions
import
ImproperlyConfigured
from
django.utils
import
importlib
from
django.utils
import
importlib
from
django.utils.encoding
import
smart_unicode
,
smart_str
from
django.utils.datastructures
import
SortedDict
from
django.utils.datastructures
import
SortedDict
from
.compat
import
smart_text
,
smart_bytes
try
:
try
:
import
cPickle
as
pickle
import
cPickle
as
pickle
...
@@ -35,7 +35,7 @@ class CacheKey(object):
...
@@ -35,7 +35,7 @@ class CacheKey(object):
return
self
.
__unicode__
()
return
self
.
__unicode__
()
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
smart_
str
(
self
.
_key
)
return
smart_
text
(
self
.
_key
)
class
CacheConnectionPool
(
object
):
class
CacheConnectionPool
(
object
):
...
@@ -243,7 +243,7 @@ class CacheClass(BaseCache):
...
@@ -243,7 +243,7 @@ class CacheClass(BaseCache):
"""
"""
Unpickles the given value.
Unpickles the given value.
"""
"""
value
=
smart_
str
(
value
)
value
=
smart_
bytes
(
value
)
return
pickle
.
loads
(
value
)
return
pickle
.
loads
(
value
)
def
get_many
(
self
,
keys
,
version
=
None
):
def
get_many
(
self
,
keys
,
version
=
None
):
...
@@ -264,7 +264,7 @@ class CacheClass(BaseCache):
...
@@ -264,7 +264,7 @@ class CacheClass(BaseCache):
except
(
ValueError
,
TypeError
):
except
(
ValueError
,
TypeError
):
value
=
self
.
unpickle
(
value
)
value
=
self
.
unpickle
(
value
)
if
isinstance
(
value
,
basestring
):
if
isinstance
(
value
,
basestring
):
value
=
smart_
unicode
(
value
)
value
=
smart_
text
(
value
)
recovered_data
[
map_keys
[
key
]]
=
value
recovered_data
[
map_keys
[
key
]]
=
value
return
recovered_data
return
recovered_data
...
...
redis_cache/compat.py
0 → 100644
View file @
59caf9cd
try
:
# Django 1.5+
from
django.utils.encoding
import
smart_text
,
smart_bytes
except
ImportError
:
# older Django, thus definitely Python 2
from
django.utils.encoding
import
smart_unicode
,
smart_str
smart_text
=
smart_unicode
smart_bytes
=
smart_str
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment