Ticket #1553: 0001-journalentrybundle-Accept-plain-JSON-in-a-Journal-E.patch

File 0001-journalentrybundle-Accept-plain-JSON-in-a-Journal-E.patch, 1.5 KB (added by martin.langhoff, 14 years ago)
  • src/jarabe/journal/journalentrybundle.py

    From ac93b69183fcf71e6efa0dd70bf16369824adc45 Mon Sep 17 00:00:00 2001
    From: Martin Langhoff <martin@laptop.org>
    Date: Thu, 12 Nov 2009 14:06:10 +0000
    Subject: [PATCH] journalentrybundle: Accept plain JSON in a Journal Entry Bundle
    
    The metadata for the Journal Entry Bundle is expected to be valid
    JSON. the CJSON parser is a lot more strict, and will parse incorrectly
    valid metadata.
    
    External systems -- such as Moodle -- create JEBs for Sugar and do not
    have a CJSON implementation.
    ---
     src/jarabe/journal/journalentrybundle.py |    6 ++++--
     1 files changed, 4 insertions(+), 2 deletions(-)
    
    diff --git a/src/jarabe/journal/journalentrybundle.py b/src/jarabe/journal/journalentrybundle.py
    index 3bc1430..f52233d 100644
    a b import os 
    1818import tempfile
    1919import shutil
    2020
    21 import cjson
     21import json
    2222import dbus
    2323
    2424from sugar.bundle.bundle import Bundle, MalformedBundleException
    class JournalEntryBundle(Bundle): 
    6565        if not os.path.exists(metadata_path):
    6666            raise MalformedBundleException(
    6767                    'Bundle must contain the file "_metadata.json"')
    68         return cjson.decode(open(metadata_path, 'r').read())
     68        # use json instead of cjson -- some JEB producers
     69        # can't/won't write cjson
     70        return json.load(open(metadata_path, 'r'))
    6971
    7072    def _read_preview(self, uid, bundle_dir):
    7173        preview_path = os.path.join(bundle_dir, 'preview', uid)