File tree 8 files changed +41
-4
lines changed
8 files changed +41
-4
lines changed Original file line number Diff line number Diff line change 1
1
Release Notes
2
2
=============
3
3
4
+ v0.6.1
5
+ ------
6
+
7
+ * Modify cache name, to prevent warnings for non-ASCII characters or
8
+ whitespace (thanks @ad-m).
9
+
4
10
v0.6.0
5
11
------
6
12
Original file line number Diff line number Diff line change 50
50
# built documents.
51
51
#
52
52
# The short X.Y version.
53
- version = '0.6.0 '
53
+ version = '0.6.1 '
54
54
# The full version, including alpha/beta/rc tags.
55
- release = '0.6.0 '
55
+ release = '0.6.1 '
56
56
57
57
# The language for content autogenerated by Sphinx. Refer to documentation
58
58
# for a list of supported languages.
Original file line number Diff line number Diff line change 1
1
[wheel]
2
2
universal = 1
3
+
4
+ [flake8]
5
+ ignore = F999
Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ def simple_content():
17
17
return content
18
18
19
19
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
+
20
29
@pytest .fixture ()
21
30
def split_content ():
22
31
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):
13
13
assert "This is a test." == render_template (
14
14
"{% tinycontent_simple 'foobar' %}"
15
15
)
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 '
2
2
VERSION = tuple (map (int , __version__ .split ('.' )))
Original file line number Diff line number Diff line change
1
+ import base64
1
2
import django
3
+ from django .utils import six
2
4
3
5
4
6
if django .VERSION > (1 , 8 ,):
@@ -43,3 +45,12 @@ def render_to_string(
43
45
"Using the request keyword argument requires Django >= 1.8"
44
46
)
45
47
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 3
3
from django .db import models
4
4
from django .utils .encoding import python_2_unicode_compatible
5
5
from tinycontent .conf import get_filter_list
6
+ from tinycontent .compat import cache_safe_key
6
7
7
8
8
9
@python_2_unicode_compatible
@@ -36,7 +37,7 @@ def get_content_by_name(name):
36
37
37
38
@staticmethod
38
39
def get_cache_key (name ):
39
- return 'tinycontent_%s' % name
40
+ return 'tinycontent_%s' % cache_safe_key ( name )
40
41
41
42
def delete (self , * args , ** kwargs ):
42
43
cache .delete (TinyContent .get_cache_key (self .name ))
You can’t perform that action at this time.
0 commit comments