[Checkins] SVN: z3c.json/trunk/ A little bit of cleanup and getting
ready for the release.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Thu Jan 24 13:01:05 EST 2008
Log message for revision 83185:
A little bit of cleanup and getting ready for the release.
Changed:
U z3c.json/trunk/CHANGES.txt
U z3c.json/trunk/README.txt
U z3c.json/trunk/TODO.txt
U z3c.json/trunk/setup.py
U z3c.json/trunk/src/z3c/json/README.txt
U z3c.json/trunk/src/z3c/json/tests.py
U z3c.json/trunk/src/z3c/json/transport.py
-=-
Modified: z3c.json/trunk/CHANGES.txt
===================================================================
--- z3c.json/trunk/CHANGES.txt 2008-01-24 17:54:28 UTC (rev 83184)
+++ z3c.json/trunk/CHANGES.txt 2008-01-24 18:01:04 UTC (rev 83185)
@@ -2,13 +2,13 @@
CHANGES
=======
-0.5.1dev (unreleased)
+0.5.1dev (2008-01-24)
---------------------
-- ...
+- Improved meta-data.
-0.5.0 (2007-01-21)
+0.5.0 (2008-01-21)
------------------
- Initial Release
Modified: z3c.json/trunk/README.txt
===================================================================
--- z3c.json/trunk/README.txt 2008-01-24 17:54:28 UTC (rev 83184)
+++ z3c.json/trunk/README.txt 2008-01-24 18:01:04 UTC (rev 83185)
@@ -1,4 +1,3 @@
-This package provides basic JSON components like JSON reader and writer
-utilities and a JSON-RPC client proxy including the transport implementation
+This package provides basic JSON components like JSON reader and writer
+utilities and a JSON-RPC client proxy including the transport implementation
for Zope3.
-
\ No newline at end of file
Modified: z3c.json/trunk/TODO.txt
===================================================================
--- z3c.json/trunk/TODO.txt 2008-01-24 17:54:28 UTC (rev 83184)
+++ z3c.json/trunk/TODO.txt 2008-01-24 18:01:04 UTC (rev 83185)
@@ -2,7 +2,7 @@
TODO
====
-- add tests and use testing stub for fake the JSONRPC server response
+- Add tests and use testing stub for fake the JSONRPC server response.
-- improve coverage, write tests for all untested code, most of this is related
+- Improve coverage, write tests for all untested code, most of this is related
to error handling.
Modified: z3c.json/trunk/setup.py
===================================================================
--- z3c.json/trunk/setup.py 2008-01-24 17:54:28 UTC (rev 83184)
+++ z3c.json/trunk/setup.py 2008-01-24 18:01:04 UTC (rev 83185)
@@ -23,13 +23,18 @@
setup (
name='z3c.json',
- version='0.5.1dev',
+ version='0.5.1',
author = "Roger Ineichen and the Zope Community",
- author_email = "zope3-dev at zope.org",
- description = "Zope3 JSON base libraries used for z3c.jsonpage and z3c.jsonrpc",
+ author_email = "zope-dev at zope.org",
+ description = "Zope3 JSON base libraries",
long_description=(
read('README.txt')
+ '\n\n' +
+ 'Detailed Documentation\n'
+ '**********************'
+ + '\n\n' +
+ read('src', 'z3c', 'json', 'README.txt')
+ + '\n\n' +
read('CHANGES.txt')
),
license = "ZPL 2.1",
@@ -44,7 +49,7 @@
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope3'],
- url = 'http://cheeseshop.python.org/pypi/z3c.json',
+ url = 'http://pypi.python.org/pypi/z3c.json',
packages = find_packages('src'),
include_package_data = True,
package_dir = {'':'src'},
@@ -58,6 +63,5 @@
'setuptools',
'zope.component',
],
- dependency_links = ['http://download.zope.org/distribution'],
zip_safe = False,
)
Modified: z3c.json/trunk/src/z3c/json/README.txt
===================================================================
--- z3c.json/trunk/src/z3c/json/README.txt 2008-01-24 17:54:28 UTC (rev 83184)
+++ z3c.json/trunk/src/z3c/json/README.txt 2008-01-24 18:01:04 UTC (rev 83185)
@@ -2,31 +2,35 @@
README
======
-We can use the JSONReader and JSONWriter if we need to convert something from
-or to JSON. Let's check the utilities:
+We can use the `JSONReader` and `JSONWriter` if we need to convert a data
+structure to or from JSON syntax -- in other words a EcmaScript mapping
+object. Let's check the utilities:
>>> import zope.component
>>> from z3c.json import interfaces
>>> from z3c.json import testing
>>> testing.setUpJSONConverter()
-JSONWRiter
-----------
+`JSONWriter` Utility
+--------------------
+
>>> jsonWriter = zope.component.getUtility(interfaces.IJSONWriter)
>>> jsonWriter
<z3c.json.converter.JSONWriter object at ...>
Read some data:
- >>> input = {u'a':['fred',7],u'b':['mary',1.234]}
+ >>> input = {u'a': ['fred', 7],
+ ... u'b':['mary', 1.234]}
>>> jsonStr = jsonWriter.write(input)
>>> jsonStr
u'{"a":["fred",7],"b":["mary",1.234]}'
-JSONReader
-----------
+`JSONReader` Utility
+--------------------
+
>>> jsonReader = zope.component.getUtility(interfaces.IJSONReader)
>>> jsonReader
<z3c.json.converter.JSONReader object at ...>
Modified: z3c.json/trunk/src/z3c/json/tests.py
===================================================================
--- z3c.json/trunk/src/z3c/json/tests.py 2008-01-24 17:54:28 UTC (rev 83184)
+++ z3c.json/trunk/src/z3c/json/tests.py 2008-01-24 18:01:04 UTC (rev 83185)
@@ -475,26 +475,26 @@
r = json.write(obj, 'utf-8')
#cannot assertEqual here, but the printed representation should be readable
#self.assertEqual(unicode(r,'utf-8'), good_composite_result)
-
+
#these tests from Koen van der Sande; just in case we really want literal
# '\n' sent across the wire.
-
+
def testReadSpecialEscapedChars1(self):
test = r'"\\f"'
self.assertEqual([ord(x) for x in json.read(test)],[92,102])
-
+
def testReadSpecialEscapedChars2(self):
test = r'"\\a"'
self.assertEqual([ord(x) for x in json.read(test)],[92,97])
-
+
def testReadSpecialEscapedChars3(self):
test = r'"\\\\a"'
self.assertEqual([ord(x) for x in json.read(test)],[92,92,97])
-
+
def testReadSpecialEscapedChars4(self):
test = r'"\\\\b"'
self.assertEqual([ord(x) for x in json.read(test)],[92,92,98])
-
+
def testReadSpecialEscapedChars5(self):
test = r'"\\\n"'
self.assertEqual([ord(x) for x in json.read(test)],[92,10])
@@ -514,7 +514,7 @@
def do_GET(self):
#print "GET"
-
+
if self.path.endswith('robots.txt'):
self.send_response(404)
self.send_header('Connection', 'close')
@@ -524,7 +524,7 @@
global next_response_status
global next_response_reason
global next_response_type
-
+
if next_response_body is None:
self.send_response(500)
self.send_header('Connection', 'close')
@@ -539,19 +539,19 @@
def do_POST(self):
#print "POST"
-
+
body = self.rfile.read(int(self.headers['content-length']))
-
+
#print body
-
+
global last_request_body
last_request_body = body
-
+
global next_response_body
global next_response_status
global next_response_reason
global next_response_type
-
+
self.send_response(next_response_status)
self.send_header('Connection', 'close')
self.send_header('Content-type', next_response_type)
@@ -563,15 +563,15 @@
pass
def set_next_response(
- response_body=None,
+ response_body=None,
response_status=200, response_reason='OK',
response_type="text/html"):
-
+
global next_response_body
global next_response_status
global next_response_reason
global next_response_type
-
+
next_response_body = response_body
next_response_status = response_status
next_response_reason = response_reason
@@ -585,13 +585,13 @@
json = JSONWriter()
data = json.write(wrapper)
-
+
set_next_response(data,
response_type="application/x-javascript;charset=utf-8"
)
-
-
+
+
def get_last_request():
global last_request_body
return last_request_body
@@ -630,46 +630,46 @@
zope.component.provideUtility(JSONReader(), IJSONReader)
setUpServer(self)
-
+
def tearDown(self):
tearDownServer(self)
-
+
def testSimple(self):
#from pub.dbgpclient import brk; brk('172.16.144.39')
proxy = JSONRPCProxy('http://localhost:%d/' % self.TEST_PORT)
-
+
set_next_response_json(True, "jsonrpc")
-
+
y = proxy.hello()
self.assertEqual(y, True)
-
+
x = get_last_request()
self.assertEqual(x,
"""{"version":"1.1","params":{},"method":"hello","id":"jsonrpc"}""")
-
-
-
+
+
+
set_next_response_json(123, "jsonrpc")
-
+
y = proxy.greeting(u'Jessy')
-
+
self.assertEqual(y, 123)
-
+
x = get_last_request()
self.assertEqual(x,
"""{"version":"1.1","params":["Jessy"],"method":"greeting","id":"jsonrpc"}""")
-
-
+
+
set_next_response('blabla')
-
+
try:
y = proxy.hello()
except ResponseError:
pass
else:
self.fail("ResponseError expected")
-
+
set_next_response('{blabla}')
try:
y = proxy.hello()
@@ -677,7 +677,7 @@
pass
else:
self.fail("ResponseError expected")
-
+
dataToTest = [
{'response_json': True,
'call_method': 'hello',
@@ -702,7 +702,7 @@
'exception': ProtocolError,
},
]
-
+
def testDataDriven(self):
for item in self.dataToTest:
jsonid = item.get('proxy_jsonid', None)
@@ -710,7 +710,7 @@
proxy = JSONRPCProxy('http://localhost:%d/' % self.TEST_PORT,
transport=transport,
jsonId=jsonid)
-
+
if 'response_json' in item:
#set response based on JSON data
error = item.get('response_json_error', None)
@@ -722,15 +722,15 @@
response_status=item.get('response_status', 200)
response_reason=item.get('response_reason', 'OK')
response_type=item.get('response_type',"text/html")
-
+
set_next_response(item['response'], response_status,
response_reason, response_type)
-
+
args = item.get('call_args', [])
kwargs = item.get('call_kwargs', {})
exception = item.get('exception', None)
method = getattr(proxy, item['call_method'])
-
+
if exception:
try:
retval = method(*args, **kwargs)
@@ -738,7 +738,7 @@
pass
else:
self.fail("%s expected" % str(exception.__class__))
-
+
if 'assert_request' in item:
x = get_last_request()
self.assertEqual(x, item['assert_request'])
Modified: z3c.json/trunk/src/z3c/json/transport.py
===================================================================
--- z3c.json/trunk/src/z3c/json/transport.py 2008-01-24 17:54:28 UTC (rev 83184)
+++ z3c.json/trunk/src/z3c/json/transport.py 2008-01-24 18:01:04 UTC (rev 83185)
@@ -37,7 +37,7 @@
class Unmarshaller(object):
def __init__(self):
self.data = None
-
+
def feed(self, data):
if self.data is None:
self.data = data
@@ -54,7 +54,7 @@
def __init__(self, unmarshaller):
self._target = unmarshaller
self.data = None
-
+
def feed(self, data):
if self.data is None:
self.data = data
More information about the Checkins
mailing list