Merge lp:~hideaki-t/wikkid/unicode_test into lp:wikkid

Proposed by Hideaki Takahashi
Status: Needs review
Proposed branch: lp:~hideaki-t/wikkid/unicode_test
Merge into: lp:wikkid
Diff against target: 146 lines (+17/-13)
7 files modified
wikkid/app.py (+1/-1)
wikkid/dispatcher.py (+2/-2)
wikkid/filestore/bzr.py (+8/-6)
wikkid/formatter/creoleformatter.py (+1/-0)
wikkid/skin/loader.py (+1/-1)
wikkid/view/textfile.py (+3/-2)
wikkid/view/urls.py (+1/-1)
To merge this branch: bzr merge lp:~hideaki-t/wikkid/unicode_test
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Needs Fixing
Wikkid Hackers Pending
Review via email: mp+60980@code.launchpad.net

Description of the change

I developed non-ASCII character support(path/URI, contents) for wikkid.
I think this contains the solution for Bug #614286(without creole parser changes)

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

On Sat, 14 May 2011 16:53:24 you wrote:
> Hideaki Takahashi has proposed merging lp:~hideaki-t/wikkid/unicode_test
> into lp:wikkid.
>
> Requested reviews:
> Wikkid Hackers (wikkid)
>
> For more details, see:
> https://code.launchpad.net/~hideaki-t/wikkid/unicode_test/+merge/60980
>
> I developed non-ASCII character support(path/URI, contents) for wikkid.
> I think this contains the solution for Bug #614286(without creole parser
> changes)

Thanks for that. the changes generally look good.

Do you have any suggestions for testing it?

Tim

Revision history for this message
Hideaki Takahashi (hideaki-t) wrote :

Hello,
I'm sorry my delay.

Thank you for your review.

Ideally all operations should be tested.

I think the following tests will be performed at least.
 * file/uri operations(non-ASCII)
  * create new file
  * open(view)
  * edit & save
  * display the file name in a list view
 * contentes rendering
  * rendering the contents that contains non-ASCII characters.

Actually I have not unittested that yet. It was regression tested by "make check". and I tested it for the Japanese characters handling using web browser manually.

I propose to create(or add) Japanese version of existing tests. What do you think?
(maybe it is ugly for non japanese speakers if I add Japanese version to existing tests.)

And, I think it should be tested by Latin characters. I just tested it for Japanese characters.

Hideaki

Revision history for this message
Aaron Bentley (abentley) wrote :

This doesn't look correct, because the WorkingTree API accepts unicode strings (e.g. in path2id), not bytes or escaped values.

review: Needs Fixing
Revision history for this message
Hideaki Takahashi (hideaki-t) wrote :

Thank you for pointing that out. I did not realize that specs.
I'll check and fix the issue.

Hideaki

Unmerged revisions

61. By Hideaki Takahashi

revert #50/#51.

pass unicode string to the creole parser.

60. By Hideaki Takahashi

support non-ascii contents in preview.

59. By Hideaki Takahashi

merge trunk

58. By Hideaki Takahashi

merge trunk changes.

57. By Hideaki Takahashi

merge trunk changes

56. By Hideaki Takahashi

Convert content to utf-8.
Use safe_utf8 function provided by bzrlib to convert to utf-8.

55. By Hideaki Takahashi

don't decode string object.

54. By Hideaki Takahashi

Support MS Windows environment.
Use os module insted of bzrlib.urlutils for non bzr controled contents.

53. By Hideaki Takahashi

At first, convert the path string to unicode.

52. By Hideaki Takahashi

support non ascii filename/URI

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'wikkid/app.py'
--- wikkid/app.py 2010-11-22 00:00:31 +0000
+++ wikkid/app.py 2011-05-14 04:53:22 +0000
@@ -64,7 +64,7 @@
64 request = Request(environ)64 request = Request(environ)
6565
66 # TODO: reject requests that aren't GET or POST66 # TODO: reject requests that aren't GET or POST
67 path = urllib.unquote(request.path)67 path = urllib.unquote(request.path).decode('utf-8')
68 if path == '/favicon.ico':68 if path == '/favicon.ico':
69 if self.skin.favicon is not None:69 if self.skin.favicon is not None:
70 response = serve_file(self.skin.favicon)70 response = serve_file(self.skin.favicon)
7171
=== modified file 'wikkid/dispatcher.py'
--- wikkid/dispatcher.py 2010-11-12 09:00:42 +0000
+++ wikkid/dispatcher.py 2011-05-14 04:53:22 +0000
@@ -13,7 +13,7 @@
1313
14import os14import os
1515
16from bzrlib.urlutils import dirname, joinpath16from bzrlib.urlutils import joinpath
1717
18from zope.interface import providedBy18from zope.interface import providedBy
1919
@@ -69,7 +69,7 @@
69# themselves with the view registry.69# themselves with the view registry.
7070
71def load_view_modules():71def load_view_modules():
72 curr_dir = os.path.abspath(dirname(__file__))72 curr_dir = os.path.abspath(os.path.dirname(__file__))
73 view_dir = joinpath(curr_dir, 'view')73 view_dir = joinpath(curr_dir, 'view')
74 py_files = [74 py_files = [
75 filename for filename in os.listdir(view_dir)75 filename for filename in os.listdir(view_dir)
7676
=== modified file 'wikkid/filestore/bzr.py'
--- wikkid/filestore/bzr.py 2010-10-17 01:47:00 +0000
+++ wikkid/filestore/bzr.py 2011-05-14 04:53:22 +0000
@@ -13,10 +13,10 @@
1313
14from bzrlib.errors import BinaryFile14from bzrlib.errors import BinaryFile
15from bzrlib.merge3 import Merge315from bzrlib.merge3 import Merge3
16from bzrlib.osutils import split_lines16from bzrlib.osutils import split_lines, safe_utf8
17from bzrlib.revision import NULL_REVISION17from bzrlib.revision import NULL_REVISION
18from bzrlib.textfile import check_text_path18from bzrlib.textfile import check_text_path
19from bzrlib.urlutils import basename, dirname, joinpath19from bzrlib.urlutils import basename, dirname, joinpath, escape
2020
21from wikkid.errors import FileExists, UpdateConflicts21from wikkid.errors import FileExists, UpdateConflicts
22from wikkid.filestore.basefile import BaseFile22from wikkid.filestore.basefile import BaseFile
@@ -66,6 +66,9 @@
66 commit_message = 'No description of change given.'66 commit_message = 'No description of change given.'
67 if parent_revision is None:67 if parent_revision is None:
68 parent_revision = NULL_REVISION68 parent_revision = NULL_REVISION
69 # bzr transport expects URL(ASCII only)
70 path = escape(path)
71 content = safe_utf8(content)
69 # Firstly we want to lock the tree for writing.72 # Firstly we want to lock the tree for writing.
70 self.working_tree.lock_write()73 self.working_tree.lock_write()
71 try:74 try:
@@ -118,7 +121,6 @@
118 t = t.clone(dirname(path))121 t = t.clone(dirname(path))
119 t.create_prefix()122 t.create_prefix()
120 # Put the file there.123 # Put the file there.
121 # TODO: UTF-8 encode text files?
122 t.put_bytes(basename(path), content)124 t.put_bytes(basename(path), content)
123 self.working_tree.smart_add([t.local_abspath('.')])125 self.working_tree.smart_add([t.local_abspath('.')])
124 self.working_tree.commit(126 self.working_tree.commit(
@@ -153,12 +155,12 @@
153 if len(new_lines) > 0 and not new_lines[-1].endswith(ending):155 if len(new_lines) > 0 and not new_lines[-1].endswith(ending):
154 new_lines[-1] += ending156 new_lines[-1] += ending
155 merge = Merge3(basis_lines, new_lines, current_lines)157 merge = Merge3(basis_lines, new_lines, current_lines)
156 result = list(merge.merge_lines()) # or merge_regions or whatever158 result = ''.join(merge.merge_lines()) # or merge_regions or whatever
157 conflicted = ('>>>>>>>' + ending) in result159 conflicted = ('>>>>>>>' + ending) in result
158 if conflicted:160 if conflicted:
159 raise UpdateConflicts(''.join(result), current_rev)161 raise UpdateConflicts(result, current_rev)
160 else:162 else:
161 wt.bzrdir.root_transport.put_bytes(path, ''.join(result))163 wt.bzrdir.root_transport.put_bytes(path, result)
162 wt.commit(164 wt.commit(
163 message=commit_message, authors=[author],165 message=commit_message, authors=[author],
164 specific_files=[path])166 specific_files=[path])
165167
=== modified file 'wikkid/formatter/creoleformatter.py'
--- wikkid/formatter/creoleformatter.py 2010-05-12 10:39:13 +0000
+++ wikkid/formatter/creoleformatter.py 2011-05-14 04:53:22 +0000
@@ -30,4 +30,5 @@
3030
31 def format(self, filename, text):31 def format(self, filename, text):
32 """Format the text."""32 """Format the text."""
33 text = text.decode('utf-8')
33 return HtmlEmitter(Parser(text, self.rules).parse()).emit()34 return HtmlEmitter(Parser(text, self.rules).parse()).emit()
3435
=== modified file 'wikkid/skin/loader.py'
--- wikkid/skin/loader.py 2010-11-05 07:43:31 +0000
+++ wikkid/skin/loader.py 2011-05-14 04:53:22 +0000
@@ -39,7 +39,7 @@
39 'missing': self.env.get_template('missing-page.html'),39 'missing': self.env.get_template('missing-page.html'),
40 'missing-dir' : self.env.get_template('missing-directory.html')40 'missing-dir' : self.env.get_template('missing-directory.html')
41 }41 }
42 module_location = urlutils.dirname(__file__)42 module_location = os.path.dirname(__file__)
43 self.dir_name = urlutils.joinpath(module_location, skin_name)43 self.dir_name = urlutils.joinpath(module_location, skin_name)
4444
45 def get_template(self, template_name):45 def get_template(self, template_name):
4646
=== modified file 'wikkid/view/textfile.py'
--- wikkid/view/textfile.py 2011-04-23 08:49:27 +0000
+++ wikkid/view/textfile.py 2011-05-14 04:53:22 +0000
@@ -7,6 +7,7 @@
7"""View classes to control the rendering of text pages."""7"""View classes to control the rendering of text pages."""
88
9import logging9import logging
10from urllib import quote
1011
11from webob.exc import HTTPSeeOther12from webob.exc import HTTPSeeOther
1213
@@ -64,13 +65,13 @@
64 self.content = content65 self.content = content
65 default_format = self.execution_context.default_format66 default_format = self.execution_context.default_format
66 self.preview_content = format_content(67 self.preview_content = format_content(
67 content, self.context.base_name, default_format)68 content.encode('utf-8'), self.context.base_name, default_format)
68 else:69 else:
69 try:70 try:
70 self.context.put_bytes(71 self.context.put_bytes(
71 content, self.user.committer_id, rev_id, description)72 content, self.user.committer_id, rev_id, description)
7273
73 raise HTTPSeeOther(location=self.context.path)74 raise HTTPSeeOther(location=quote(self.context.path.encode('utf-8')))
74 except UpdateConflicts, e:75 except UpdateConflicts, e:
75 # Show the edit page again.76 # Show the edit page again.
76 logger = logging.getLogger('wikkid')77 logger = logging.getLogger('wikkid')
7778
=== modified file 'wikkid/view/urls.py'
--- wikkid/view/urls.py 2010-06-16 10:29:35 +0000
+++ wikkid/view/urls.py 2011-05-14 04:53:22 +0000
@@ -32,4 +32,4 @@
32 else:32 else:
33 if path == '/':33 if path == '/':
34 path = ''34 path = ''
35 return '{0}/+{1}'.format(path, view)35 return u'{0}/+{1}'.format(path, view)

Subscribers

People subscribed via source and target branches