File tree Expand file tree Collapse file tree 8 files changed +41
-4
lines changed
Expand file tree Collapse file tree 8 files changed +41
-4
lines changed Original file line number Diff line number Diff line change 11Release Notes
22=============
33
4+ v0.6.1
5+ ------
6+
7+ * Modify cache name, to prevent warnings for non-ASCII characters or
8+ whitespace (thanks @ad-m).
9+
410v0.6.0
511------
612
Original file line number Diff line number Diff line change 5050# built documents.
5151#
5252# The short X.Y version.
53- version = '0.6.0 '
53+ version = '0.6.1 '
5454# The full version, including alpha/beta/rc tags.
55- release = '0.6.0 '
55+ release = '0.6.1 '
5656
5757# The language for content autogenerated by Sphinx. Refer to documentation
5858# for a list of supported languages.
Original file line number Diff line number Diff line change 11[wheel]
22universal = 1
3+
4+ [flake8]
5+ ignore = F999
Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ def simple_content():
1717 return content
1818
1919
20+ @pytest .fixture ()
21+ def simple_content_with_space ():
22+ content , _ = TinyContent .objects .get_or_create (
23+ name = 'foo bar' ,
24+ content = 'This is a test with a space.'
25+ )
26+ return content
27+
28+
2029@pytest .fixture ()
2130def split_content ():
2231 content , _ = TinyContent .objects .get_or_create (
Original file line number Diff line number Diff line change @@ -13,3 +13,10 @@ def test_simple_existent(simple_content):
1313 assert "This is a test." == render_template (
1414 "{% tinycontent_simple 'foobar' %}"
1515 )
16+
17+
18+ @pytest .mark .django_db
19+ def test_simple_with_space (simple_content_with_space ):
20+ assert "This is a test with a space." == render_template (
21+ "{% tinycontent_simple 'foo bar' %}"
22+ )
Original file line number Diff line number Diff line change 1- __version__ = '0.6.0 '
1+ __version__ = '0.6.1 '
22VERSION = tuple (map (int , __version__ .split ('.' )))
Original file line number Diff line number Diff line change 1+ import base64
12import django
3+ from django .utils import six
24
35
46if django .VERSION > (1 , 8 ,):
@@ -43,3 +45,12 @@ def render_to_string(
4345 "Using the request keyword argument requires Django >= 1.8"
4446 )
4547 return _render_to_string (template_name , context )
48+
49+
50+ def cache_safe_key (key ):
51+ if six .PY2 :
52+ return base64 .b64encode (
53+ key
54+ )
55+
56+ return base64 .b64encode (bytes (key , 'utf-8' ))
Original file line number Diff line number Diff line change 33from django .db import models
44from django .utils .encoding import python_2_unicode_compatible
55from tinycontent .conf import get_filter_list
6+ from tinycontent .compat import cache_safe_key
67
78
89@python_2_unicode_compatible
@@ -36,7 +37,7 @@ def get_content_by_name(name):
3637
3738 @staticmethod
3839 def get_cache_key (name ):
39- return 'tinycontent_%s' % name
40+ return 'tinycontent_%s' % cache_safe_key ( name )
4041
4142 def delete (self , * args , ** kwargs ):
4243 cache .delete (TinyContent .get_cache_key (self .name ))
You can’t perform that action at this time.
0 commit comments