Attachments you submit will be routed for moderation. If you have an account, please
log in first.
Ticket #1553: 0001-Revert-Move-to-cjson-and-drop-pyjson-and-simplejson.patch
|
File 0001-Revert-Move-to-cjson-and-drop-pyjson-and-simplejson.patch, 5.4 KB
(added by dsd, 4 years ago)
|
|
patch
|
-
From 97c978092da7f66db0f6f58782a7bee801fde5ac Mon Sep 17 00:00:00 2001
From: Daniel Drake <dsd@laptop.org>
Date: Wed, 18 Nov 2009 12:17:47 +0000
Subject: [PATCH] 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
---
src/jarabe/journal/expandedentry.py | 6 ++++--
src/jarabe/journal/journalentrybundle.py | 9 +++++++--
src/jarabe/journal/listmodel.py | 6 ++++--
src/jarabe/model/bundleregistry.py | 6 +++---
src/jarabe/model/owner.py | 4 ++--
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
|
b
|
|
| 23 | 23 | import cairo |
| 24 | 24 | import gobject |
| 25 | 25 | import gtk |
| 26 | | import cjson |
| | 26 | import json |
| 27 | 27 | |
| 28 | 28 | from sugar.graphics import style |
| 29 | 29 | from sugar.graphics.icon import CanvasIcon |
| … |
… |
|
| 303 | 303 | |
| 304 | 304 | if self._metadata.has_key('buddies') and \ |
| 305 | 305 | self._metadata['buddies']: |
| 306 | | buddies = cjson.decode(self._metadata['buddies']).values() |
| | 306 | # json cannot read unicode strings |
| | 307 | buddies_str = self._metadata['buddies'].encode('utf8') |
| | 308 | buddies = json.read(buddies_str).values() |
| 307 | 309 | vbox.append(BuddyList(buddies)) |
| 308 | 310 | return vbox |
| 309 | 311 | else: |
-
diff --git a/src/jarabe/journal/journalentrybundle.py b/src/jarabe/journal/journalentrybundle.py
index ebe7ec3..a0bc935 100644
|
a
|
b
|
|
| 18 | 18 | import tempfile |
| 19 | 19 | import shutil |
| 20 | 20 | |
| 21 | | import cjson |
| | 21 | import json |
| 22 | 22 | import dbus |
| 23 | 23 | |
| 24 | 24 | from sugar.bundle.bundle import Bundle, MalformedBundleException |
| … |
… |
|
| 70 | 70 | if not os.path.exists(metadata_path): |
| 71 | 71 | raise MalformedBundleException( |
| 72 | 72 | 'Bundle must contain the file "_metadata.json"') |
| 73 | | return cjson.decode(open(metadata_path, 'r').read()) |
| | 73 | f = open(metadata_path, 'r') |
| | 74 | try: |
| | 75 | json_data = f.read() |
| | 76 | finally: |
| | 77 | f.close() |
| | 78 | return json.read(json_data) |
| 74 | 79 | |
| 75 | 80 | def _read_preview(self, uid, bundle_dir): |
| 76 | 81 | 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
|
b
|
|
| 16 | 16 | |
| 17 | 17 | import logging |
| 18 | 18 | |
| 19 | | import cjson |
| | 19 | import json |
| 20 | 20 | import gobject |
| 21 | 21 | import gtk |
| 22 | 22 | |
| … |
… |
|
| 144 | 144 | self._cached_row.append(int(metadata.get('progress', 100))) |
| 145 | 145 | |
| 146 | 146 | if metadata.get('buddies', ''): |
| 147 | | buddies = cjson.decode(metadata['buddies']).values() |
| | 147 | # json cannot read unicode strings |
| | 148 | buddies_str = metadata['buddies'].encode('utf8') |
| | 149 | buddies = json.read(buddies_str).values() |
| 148 | 150 | else: |
| 149 | 151 | buddies = [] |
| 150 | 152 | |
-
diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
index b754952..aa49c72 100644
|
a
|
b
|
|
| 21 | 21 | |
| 22 | 22 | import gobject |
| 23 | 23 | import gio |
| 24 | | import cjson |
| | 24 | import simplejson |
| 25 | 25 | |
| 26 | 26 | from sugar.bundle.activitybundle import ActivityBundle |
| 27 | 27 | from sugar.bundle.contentbundle import ContentBundle |
| … |
… |
|
| 107 | 107 | def _load_favorites(self): |
| 108 | 108 | favorites_path = env.get_profile_path('favorite_activities') |
| 109 | 109 | if os.path.exists(favorites_path): |
| 110 | | favorites_data = cjson.decode(open(favorites_path).read()) |
| | 110 | favorites_data = simplejson.load(open(favorites_path)) |
| 111 | 111 | |
| 112 | 112 | favorite_bundles = favorites_data['favorites'] |
| 113 | 113 | if not isinstance(favorite_bundles, dict): |
| … |
… |
|
| 322 | 322 | path = env.get_profile_path('favorite_activities') |
| 323 | 323 | favorites_data = {'defaults-mtime': self._last_defaults_mtime, |
| 324 | 324 | 'favorites': self._favorite_bundles} |
| 325 | | open(path, 'w').write(cjson.encode(favorites_data)) |
| | 325 | simplejson.dump(favorites_data, open(path, 'w'), indent=1) |
| 326 | 326 | |
| 327 | 327 | def is_installed(self, bundle): |
| 328 | 328 | # 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
|
b
|
|
| 17 | 17 | |
| 18 | 18 | import gobject |
| 19 | 19 | import os |
| 20 | | import cjson |
| 21 | 20 | import gconf |
| | 21 | import simplejson |
| 22 | 22 | |
| 23 | 23 | from telepathy.interfaces import CHANNEL_TYPE_TEXT |
| 24 | 24 | |
| … |
… |
|
| 98 | 98 | bundle_id = 'org.laptop.Chat' |
| 99 | 99 | else: |
| 100 | 100 | bundle_id = 'org.laptop.VideoChat' |
| 101 | | tp_channel = cjson.encode([bus_name, connection, channel]) |
| | 101 | tp_channel = simplejson.dumps([bus_name, connection, channel]) |
| 102 | 102 | self._invites.add_private_invite(tp_channel, bundle_id) |
| 103 | 103 | |
| 104 | 104 | def _activity_disappeared_cb(self, pservice, activity): |
Download in other formats: