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-12-01 17:56:12 (GMT)
committer Daniel Drake <dsd@laptop.org>2009-12-01 17:56:12 (GMT)
commite6fcc2c22246386ffaffb2fdf9b2ca9acbf804b6 (patch)
tree0de9a0919f94f924bbaafdcacd90c92f39f9775b
parent2f9e07fa372d8bfc832bc7579fce4a9ff419207a (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 also merged in 738efb8179c9f52df5cf2e21de0acda99d09dccf Switch entirely to simplejson I misunderstood the state of affairs with the numerous json parsers. Whatever we used to have as 'json' isn't really available on Py2.6. Move to simplejson which seems to be the most functional implementation, available on both old and new setups.
-rw-r--r--src/jarabe/journal/collapsedentry.py4
-rw-r--r--src/jarabe/journal/expandedentry.py4
-rw-r--r--src/jarabe/journal/journalentrybundle.py9
-rw-r--r--src/jarabe/model/bundleregistry.py6
-rw-r--r--src/jarabe/model/owner.py4
5 files changed, 16 insertions, 11 deletions
diff --git a/src/jarabe/journal/collapsedentry.py b/src/jarabe/journal/collapsedentry.py
index 3eeb087..d3c94a1 100644
--- a/src/jarabe/journal/collapsedentry.py
+++ b/src/jarabe/journal/collapsedentry.py
@@ -20,7 +20,7 @@ from gettext import gettext as _
import gobject
import gtk
import hippo
-import cjson
+import simplejson
from sugar.graphics.icon import CanvasIcon
from sugar.graphics.xocolor import XoColor
@@ -180,7 +180,7 @@ class BaseCollapsedEntry(hippo.CanvasBox):
def _decode_buddies(self):
if self.metadata.has_key('buddies') and \
self.metadata['buddies']:
- buddies = cjson.decode(self.metadata['buddies']).values()
+ buddies = simplejson.loads(self._metadata['buddies']).values()
else:
buddies = []
return buddies
diff --git a/src/jarabe/journal/expandedentry.py b/src/jarabe/journal/expandedentry.py
index 6ef531b..b996649 100644
--- a/src/jarabe/journal/expandedentry.py
+++ b/src/jarabe/journal/expandedentry.py
@@ -22,7 +22,7 @@ import hippo
import cairo
import gobject
import gtk
-import cjson
+import simplejson
from sugar.graphics import style
from sugar.graphics.icon import CanvasIcon
@@ -234,7 +234,7 @@ class ExpandedEntry(hippo.CanvasBox):
if self._metadata.has_key('buddies') and \
self._metadata['buddies']:
- buddies = cjson.decode(self._metadata['buddies']).values()
+ buddies = simplejson.loads(self._metadata['buddies']).values()
vbox.append(BuddyList(buddies))
return vbox
else:
diff --git a/src/jarabe/journal/journalentrybundle.py b/src/jarabe/journal/journalentrybundle.py
index ebe7ec3..74b2ac5 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 simplejson
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 simplejson.loads(json_data)
def _read_preview(self, uid, bundle_dir):
preview_path = os.path.join(bundle_dir, 'preview', uid)
diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
index a3dc3ea..516c405 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -22,7 +22,7 @@ import sys
import gobject
import gio
-import cjson
+import simplejson
from sugar.bundle.activitybundle import ActivityBundle
from sugar.bundle.contentbundle import ContentBundle
@@ -105,7 +105,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):
@@ -305,7 +305,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_pre_installed(self, bundle_id):
installed = self.get_bundle(bundle_id)
diff --git a/src/jarabe/model/owner.py b/src/jarabe/model/owner.py
index bdfd9a8..b14029e 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):