[Checkins] SVN: zopyx.versioning/trunk/ switching to anyjson
Andreas Jung
andreas at andreas-jung.com
Fri Jul 2 04:25:40 EDT 2010
Log message for revision 114100:
switching to anyjson
Changed:
U zopyx.versioning/trunk/setup.py
U zopyx.versioning/trunk/zopyx/versioning/storages/mongodb/storage.py
U zopyx.versioning/trunk/zopyx/versioning/storages/mongodb/tests/test_storage.py
-=-
Modified: zopyx.versioning/trunk/setup.py
===================================================================
--- zopyx.versioning/trunk/setup.py 2010-07-02 07:50:41 UTC (rev 114099)
+++ zopyx.versioning/trunk/setup.py 2010-07-02 08:25:40 UTC (rev 114100)
@@ -6,7 +6,7 @@
setup(name='zopyx.versioning',
version=version,
description="A flexible and pluggable versioning system for schema-oriented documents",
- long_description=open("zopyx.versioning/zopyx/versioning/README.txt").read() + "\n" +
+ long_description=open("zopyx/versioning/README.txt").read() + "\n" +
open(os.path.join("docs", "HISTORY.txt")).read(),
# Get more strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
@@ -27,7 +27,7 @@
'zope.component',
'pymongo',
'unittest2',
- 'python-cjson',
+ 'anyjson',
'nose',
# -*- Extra requirements: -*-
],
Modified: zopyx.versioning/trunk/zopyx/versioning/storages/mongodb/storage.py
===================================================================
--- zopyx.versioning/trunk/zopyx/versioning/storages/mongodb/storage.py 2010-07-02 07:50:41 UTC (rev 114099)
+++ zopyx.versioning/trunk/zopyx/versioning/storages/mongodb/storage.py 2010-07-02 08:25:40 UTC (rev 114100)
@@ -2,11 +2,9 @@
Prototype storage implementation for MongoDB
"""
+import anyjson
from pymongo.connection import Connection
-from cjson import encode as json_encode
-from cjson import decode as json_decode
-
from zope.interface import implements
from zopyx.versioning.interfaces import IVersionStorage
from zopyx.versioning import errors
@@ -37,7 +35,7 @@
self.metadata.update({'_oid' : id}, {'$set' : {'_rev' : revision}} )
data = dict(_oid=id, _rev=revision)
- data.update(json_decode(version_data))
+ data.update(anyjson.deserialize(version_data))
self.revisions.save(data)
return revision
@@ -52,7 +50,7 @@
del entry['_oid']
del entry['_rev']
del entry['_id']
- return json_encode(entry)
+ return anyjson.serialize(entry)
raise errors.NoRevisionFound('No revision %d found for document with ID %s found' % (revision, id))
Modified: zopyx.versioning/trunk/zopyx/versioning/storages/mongodb/tests/test_storage.py
===================================================================
--- zopyx.versioning/trunk/zopyx/versioning/storages/mongodb/tests/test_storage.py 2010-07-02 07:50:41 UTC (rev 114099)
+++ zopyx.versioning/trunk/zopyx/versioning/storages/mongodb/tests/test_storage.py 2010-07-02 08:25:40 UTC (rev 114100)
@@ -2,10 +2,8 @@
MongoDB storage tests
"""
-from cjson import encode as json_encode
-from cjson import decode as json_decode
-
import unittest2
+import anyjson
from zope.interface.verify import verifyClass
@@ -29,7 +27,7 @@
def testStore(self):
version_data = {'text' : u'hello world', 'subject' : [u'kw1', u'kw2']}
for i in range(5):
- self.storage.store('42', json_encode(version_data), 'ajung')
+ self.storage.store('42', anyjson.serialize(version_data), 'ajung')
revisions = self.storage.list_revisions('42')
self.assertEqual(revisions, [0,1,2,3,4])
@@ -43,7 +41,7 @@
def testRemoveExistingDocument(self):
version_data = {'text' : u'hello world', 'subject' : [u'kw1', u'kw2']}
- self.storage.store('42', json_encode(version_data), 'ajung')
+ self.storage.store('42', anyjson.serialize(version_data), 'ajung')
self.storage.remove('42')
with self.assertRaises(errors.NoDocumentFound):
self.storage.remove('42')
More information about the checkins
mailing list