[Checkins] SVN: z3c.json/trunk/ - do not test for response len if response is an int
Juergen Kartnaller
juergen at kartnaller.at
Fri Nov 14 09:23:05 EST 2008
Log message for revision 92926:
- do not test for response len if response is an int
- fixed possible unicode error in case of response error
- made all tests pass (JSONWriter inserts no whitespace)
Changed:
U z3c.json/trunk/CHANGES.txt
U z3c.json/trunk/setup.py
U z3c.json/trunk/src/z3c/json/README.txt
U z3c.json/trunk/src/z3c/json/proxy.py
U z3c.json/trunk/src/z3c/json/tests.py
-=-
Modified: z3c.json/trunk/CHANGES.txt
===================================================================
--- z3c.json/trunk/CHANGES.txt 2008-11-14 14:07:58 UTC (rev 92925)
+++ z3c.json/trunk/CHANGES.txt 2008-11-14 14:23:05 UTC (rev 92926)
@@ -2,9 +2,12 @@
CHANGES
=======
-Version 0.5.2dev (unreleased)
+Version 0.5.3dev (unreleased)
-----------------------------
+- do not test for response len if response is an int
+- fixed possible unicode error in case of response error
+- made all tests pass (JSONWriter inserts no whitespace)
- added parse_response_headers to allow subclasses to handle header values if
needed.
Modified: z3c.json/trunk/setup.py
===================================================================
--- z3c.json/trunk/setup.py 2008-11-14 14:07:58 UTC (rev 92925)
+++ z3c.json/trunk/setup.py 2008-11-14 14:23:05 UTC (rev 92926)
@@ -23,7 +23,7 @@
setup (
name='z3c.json',
- version='0.5.2dev',
+ version='0.5.3dev',
author = "Roger Ineichen and the Zope Community",
author_email = "zope-dev at zope.org",
description = "Zope3 JSON base libraries",
Modified: z3c.json/trunk/src/z3c/json/README.txt
===================================================================
--- z3c.json/trunk/src/z3c/json/README.txt 2008-11-14 14:07:58 UTC (rev 92925)
+++ z3c.json/trunk/src/z3c/json/README.txt 2008-11-14 14:23:05 UTC (rev 92926)
@@ -25,7 +25,7 @@
... u'b':['mary', 1.234]}
>>> jsonStr = jsonWriter.write(input)
>>> jsonStr
- u'{"a": ["fred", 7], "b": ["mary", 1.234]}'
+ u'{"a":["fred",7],"b":["mary",1.234]}'
`JSONReader` Utility
@@ -35,7 +35,7 @@
>>> jsonReader
<z3c.json.converter.JSONReader object at ...>
-Conver the data back to python:
+Convert the data back to python:
>>> output = jsonReader.read(jsonStr)
>>> output
Modified: z3c.json/trunk/src/z3c/json/proxy.py
===================================================================
--- z3c.json/trunk/src/z3c/json/proxy.py 2008-11-14 14:07:58 UTC (rev 92925)
+++ z3c.json/trunk/src/z3c/json/proxy.py 2008-11-14 14:23:05 UTC (rev 92926)
@@ -38,13 +38,13 @@
class _Method(object):
-
+
def __init__(self, call, name, jsonId, jsonVersion):
self.call = call
self.name = name
self.jsonId = jsonId
self.jsonVersion = jsonVersion
-
+
def __call__(self, *args, **kwargs):
request = {}
# add our version
@@ -123,8 +123,8 @@
self.error = None
def __request(self, request):
- """call a method on the remote server.
-
+ """call a method on the remote server.
+
This will raise a ResponseError or return the JSON result dict
"""
# apply encoding if any
@@ -137,14 +137,13 @@
self.error = None
except ResponseError, e:
# catch error message
- self.error = unicode(e)
+ self.error = unicode(str(e), 'utf-8')
raise
if isinstance(response, int):
# that's just a status code response with no result
logger.error('Received status code %s' % response)
-
- if len(response) == 3:
+ elif len(response) == 3:
# that's a valid response format
if self.jsonId is not None and \
(self.jsonId != response.get('id')):
Modified: z3c.json/trunk/src/z3c/json/tests.py
===================================================================
--- z3c.json/trunk/src/z3c/json/tests.py 2008-11-14 14:07:58 UTC (rev 92925)
+++ z3c.json/trunk/src/z3c/json/tests.py 2008-11-14 14:23:05 UTC (rev 92926)
@@ -642,7 +642,7 @@
x = get_last_request()
self.assertEqual(x,
- """{"params": [], "jsonrpc": "2.0", "method": "hello", "id": "jsonrpc"}""")
+ """{"params":[],"jsonrpc":"2.0","method":"hello","id":"jsonrpc"}""")
set_next_response_json(123, "jsonrpc")
y = proxy.greeting(u'Jessy')
@@ -650,7 +650,7 @@
x = get_last_request()
self.assertEqual(x,
- """{"params": ["Jessy"], "jsonrpc": "2.0", "method": "greeting", "id": "jsonrpc"}""")
+ """{"params":["Jessy"],"jsonrpc":"2.0","method":"greeting","id":"jsonrpc"}""")
set_next_response('blabla')
try:
@@ -673,14 +673,14 @@
'call_method': 'hello',
'assert_retval': True,
'assert_request':
- """{"params": [], "jsonrpc": "2.0", "method": "hello", "id": "jsonrpc"}""",
+ """{"params":[],"jsonrpc":"2.0","method":"hello","id":"jsonrpc"}""",
},
{'response_json': 123,
'call_method': 'greeting',
'call_args': [u'Jessy'],
'assert_retval': 123,
'assert_request':
- """{"params": ["Jessy"], "jsonrpc": "2.0", "method": "greeting", "id": "jsonrpc"}""",
+ """{"params":["Jessy"],"jsonrpc":"2.0","method":"greeting","id":"jsonrpc"}""",
},
{'response': 'blabla',
'call_method': 'hello',
More information about the Checkins
mailing list