You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/07/09 20:21:18 UTC
git commit: [#7507] Fixed unicode decoding issue during project
serialization
Repository: allura
Updated Branches:
refs/heads/master 04e893373 -> 2b5d4b20d
[#7507] Fixed unicode decoding issue during project serialization
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/2b5d4b20
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2b5d4b20
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2b5d4b20
Branch: refs/heads/master
Commit: 2b5d4b20ddd822efa4e52b59f0e2c1896203c38c
Parents: 04e8933
Author: Alexander Luberg <al...@slashdotmedia.com>
Authored: Tue Jul 8 18:47:04 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Jul 9 18:21:00 2014 +0000
----------------------------------------------------------------------
Allura/allura/model/project.py | 4 ++--
Allura/allura/tests/model/test_project.py | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/2b5d4b20/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index c28cc8e..9db3bcd 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -1095,10 +1095,10 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
screenshots=[
dict(
url=h.absurl(self.url() + 'screenshot/' +
- urllib.quote(ss.filename)),
+ urllib.quote(ss.filename.encode('utf8'))),
thumbnail_url=h.absurl(
self.url(
- ) + 'screenshot/' + urllib.quote(ss.filename) + '/thumb'),
+ ) + 'screenshot/' + urllib.quote(ss.filename.encode('utf8')) + '/thumb'),
caption=ss.caption,
)
for ss in self.get_screenshots()
http://git-wip-us.apache.org/repos/asf/allura/blob/2b5d4b20/Allura/allura/tests/model/test_project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_project.py b/Allura/allura/tests/model/test_project.py
index 20aa059..db0c96d 100644
--- a/Allura/allura/tests/model/test_project.py
+++ b/Allura/allura/tests/model/test_project.py
@@ -158,3 +158,21 @@ def test_project_disabled_users():
ThreadLocalORMSession.flush_all()
users = p.users()
assert users == []
+
+def test_screenshot_unicode_serialization():
+ p = M.Project.query.get(shortname='test')
+ screenshot_unicode = M.ProjectFile(project_id=p._id, category='screenshot', caption=u"ConSelección", filename=u'ConSelección.jpg')
+ screenshot_ascii = M.ProjectFile(project_id=p._id, category='screenshot', caption='test-screenshot', filename='test_file.jpg')
+ ThreadLocalORMSession.flush_all()
+
+ serialized = p.__json__()
+ screenshots = sorted(serialized['screenshots'], key=lambda k: k['caption'])
+
+ assert len(screenshots) == 2
+ assert screenshots[0]['url'] == 'http://localhost/p/test/screenshot/ConSelecci%C3%B3n.jpg'
+ assert screenshots[0]['caption'] == u"ConSelección"
+ assert screenshots[0]['thumbnail_url'] == 'http://localhost/p/test/screenshot/ConSelecci%C3%B3n.jpg/thumb'
+
+ assert screenshots[1]['url'] == 'http://localhost/p/test/screenshot/test_file.jpg'
+ assert screenshots[1]['caption'] == 'test-screenshot'
+ assert screenshots[1]['thumbnail_url'] == 'http://localhost/p/test/screenshot/test_file.jpg/thumb'