Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2009-11-18 12:17:47 (GMT)
committer Daniel Drake <dsd@laptop.org>2009-11-23 11:01:46 (GMT)
commitcff9e43527ead20b088a9bfc6bbf12b0827debfd (patch)
treeb7e55fd146187bfca81a8ffccd36704fea0d93eb
parent03d80f06f184e1e1e4635f7eb284b15113126251 (diff)
Revert "Move to cjson and drop pyjson and simplejson"
This reverts commit ee4535c98ae74347e7072909d49dcf8a5e16ca7b. cjson has a big bug dealing with slashes, this is a significant long-term bug and upstream has not been responsive other than acknowledging it. This bug breaks journal entry bundles. http://dev.sugarlabs.org/ticket/1553 Thanks to Martin Langhoff for identifying and researching this issue
-rw-r--r--src/jarabe/journal/expandedentry.py6
-rw-r--r--src/jarabe/journal/journalentrybundle.py9
-rw-r--r--src/jarabe/journal/listmodel.py6
-rw-r--r--src/jarabe/model/bundleregistry.py6
-rw-r--r--src/jarabe/model/owner.py4
5 files changed, 20 insertions, 11 deletions
diff --git a/src/jarabe/journal/expandedentry.py b/src/jarabe/journal/expandedentry.py
index 94d90ed..4463cac 100644
--- a/src/jarabe/journal/expandedentry.py
+++ b/src/jarabe/journal/expandedentry.py
@@ -23,7 +23,7 @@ import hippo
import cairo
import gobject
import gtk
-import cjson
+import json
from sugar.graphics import style
from sugar.graphics.icon import CanvasIcon
@@ -303,7 +303,9 @@ class ExpandedEntry(hippo.CanvasBox):
if self._metadata.has_key('buddies') and \
self._metadata['buddies']:
- buddies = cjson.decode(self._metadata['buddies']).values()
+ # json cannot read unicode strings
+ buddies_str = self._metadata['buddies'].encode('utf8')
+ buddies = json.read(buddies_str).values()
vbox.append(BuddyList(buddies))
return vbox
else:
diff --git a/src/jarabe/journal/journalentrybundle.py b/src/jarabe/journal/journalentrybundle.py
index ebe7ec3..a0bc935 100644
--- a/src/jarabe/journal/journalentrybundle.py
+++ b/src/jarabe/journal/journalentrybundle.py
@@ -18,7 +18,7 @@ import os
import tempfile
import shutil
-import cjson
+import json
import dbus
from sugar.bundle.bundle import Bundle, MalformedBundleException
@@ -70,7 +70,12 @@ class JournalEntryBundle(Bundle):
if not os.path.exists(metadata_path):
raise MalformedBundleException(
'Bundle must contain the file "_metadata.json"')
- return cjson.decode(open(metadata_path, 'r').read())
+ f = open(metadata_path, 'r')
+ try:
+ json_data = f.read()
+ finally:
+ f.close()
+ return json.read(json_data)
def _read_preview(self, uid, bundle_dir):
preview_path = os.path.join(bundle_dir, 'preview', uid)
diff --git a/src/jarabe/journal/listmodel.py b/src/jarabe/journal/listmodel.py
index 32df853..bc53a9c 100644
--- a/src/jarabe/journal/listmodel.py
+++ b/src/jarabe/journal/listmodel.py
@@ -16,7 +16,7 @@
import logging
-import cjson
+import json
import gobject
import gtk
@@ -144,7 +144,9 @@ class ListModel(gtk.GenericTreeModel, gtk.TreeDragSource):
self._cached_row.append(int(metadata.get('progress', 100)))
if metadata.get('buddies', ''):
- buddies = cjson.decode(metadata['buddies']).values()
+ # json cannot read unicode strings
+ buddies_str = metadata['buddies'].encode('utf8')
+ buddies = json.read(buddies_str).values()
else:
buddies = []
diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
index b754952..aa49c72 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -21,7 +21,7 @@ import traceback
import gobject
import gio
-import cjson
+import simplejson
from sugar.bundle.activitybundle import ActivityBundle
from sugar.bundle.contentbundle import ContentBundle
@@ -107,7 +107,7 @@ class BundleRegistry(gobject.GObject):
def _load_favorites(self):
favorites_path = env.get_profile_path('favorite_activities')
if os.path.exists(favorites_path):
- favorites_data = cjson.decode(open(favorites_path).read())
+ favorites_data = simplejson.load(open(favorites_path))
favorite_bundles = favorites_data['favorites']
if not isinstance(favorite_bundles, dict):
@@ -322,7 +322,7 @@ class BundleRegistry(gobject.GObject):
path = env.get_profile_path('favorite_activities')
favorites_data = {'defaults-mtime': self._last_defaults_mtime,
'favorites': self._favorite_bundles}
- open(path, 'w').write(cjson.encode(favorites_data))
+ simplejson.dump(favorites_data, open(path, 'w'), indent=1)
def is_installed(self, bundle):
# TODO treat ContentBundle in special way
diff --git a/src/jarabe/model/owner.py b/src/jarabe/model/owner.py
index 2075f08..17996e6 100644
--- a/src/jarabe/model/owner.py
+++ b/src/jarabe/model/owner.py
@@ -17,8 +17,8 @@
import gobject
import os
-import cjson
import gconf
+import simplejson
from telepathy.interfaces import CHANNEL_TYPE_TEXT
@@ -98,7 +98,7 @@ class Owner(gobject.GObject):
bundle_id = 'org.laptop.Chat'
else:
bundle_id = 'org.laptop.VideoChat'
- tp_channel = cjson.encode([bus_name, connection, channel])
+ tp_channel = simplejson.dumps([bus_name, connection, channel])
self._invites.add_private_invite(tp_channel, bundle_id)
def _activity_disappeared_cb(self, pservice, activity):