File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 1
- Version 0.7
1
+ Version 0.7.0
2
2
http://couchdb-python.googlecode.com/hg/?r=default
3
3
(???, from branches/0.7.x)
4
4
@@ -17,6 +17,7 @@ http://couchdb-python.googlecode.com/hg/?r=default
17
17
* `schema.ListField` objects now have correct behavior for slicing operations
18
18
and the `pop()` method (issue 92).
19
19
* Added a `revisions()` method to the Database class (issue 99).
20
+ * Make sure we always return UTF-8 from the view server (issue 81).
20
21
21
22
22
23
Version 0.6
Original file line number Diff line number Diff line change @@ -36,6 +36,15 @@ def test_map_doc(self):
36
36
'true\n '
37
37
'[[[null, {"foo": "bar"}]]]\n ' )
38
38
39
+ def test_i18n (self ):
40
+ input = StringIO ('["add_fun", "def fun(doc): yield doc[\\ "test\\ "], doc"]\n '
41
+ '["map_doc", {"test": "b\xc3 \xa5 r"}]\n ' )
42
+ output = StringIO ()
43
+ view .run (input = input , output = output )
44
+ self .assertEqual (output .getvalue (),
45
+ 'true\n '
46
+ '[[["b\xc3 \xa5 r", {"test": "b\xc3 \xa5 r"}]]]\n ' )
47
+
39
48
def test_map_doc_with_logging (self ):
40
49
fun = 'def fun(doc): log(\' running\' ); yield None, doc'
41
50
input = StringIO ('["add_fun", "%s"]\n '
Original file line number Diff line number Diff line change @@ -32,12 +32,18 @@ def run(input=sys.stdin, output=sys.stdout):
32
32
"""
33
33
functions = []
34
34
35
+ def _writejson (obj ):
36
+ obj = json .encode (obj )
37
+ if isinstance (obj , unicode ):
38
+ obj = obj .encode ('utf-8' )
39
+ output .write (obj )
40
+ output .write ('\n ' )
41
+ output .flush ()
42
+
35
43
def _log (message ):
36
44
if not isinstance (message , basestring ):
37
45
message = json .encode (message )
38
- output .write (json .encode ({'log' : message }))
39
- output .write ('\n ' )
40
- output .flush ()
46
+ _writejson ({'log' : message })
41
47
42
48
def reset (config = None ):
43
49
del functions [:]
@@ -135,9 +141,7 @@ def rereduce(*cmd):
135
141
else :
136
142
retval = handlers [cmd [0 ]](* cmd [1 :])
137
143
log .debug ('Returning %r' , retval )
138
- output .write (json .encode (retval ))
139
- output .write ('\n ' )
140
- output .flush ()
144
+ _writejson (retval )
141
145
except KeyboardInterrupt :
142
146
return 0
143
147
except Exception , e :
You can’t perform that action at this time.
0 commit comments