Ticket #1028: 0001-Fix-ContentBundle-bundle_id.patch

File 0001-Fix-ContentBundle-bundle_id.patch, 2.5 KB (added by dsd, 15 years ago)
  • src/sugar/bundle/contentbundle.py

    From 56d2e4cd8e937cea531820faeb6d2c74d09c158e Mon Sep 17 00:00:00 2001
    From: Daniel Drake <dsd@laptop.org>
    Date: Thu, 9 Jul 2009 12:41:05 +0100
    Subject: [PATCH] Fix ContentBundle bundle_id
    
    Most content bundles use global_name as the ID-style thing, as suggested
    on the OLPC wiki. bundle_class seems undocumented and hence is not
    present in any of the content bundles I have here.
    
    Change get_bundle_id() to fall back on the global_name if no bundle_class
    is set. This fixes a complete sugar crash when installing the standard
    content bundles (it tried to send a None value over dbus).
    ---
     src/sugar/bundle/contentbundle.py |   16 +++++++++++++++-
     1 files changed, 15 insertions(+), 1 deletions(-)
    
    diff --git a/src/sugar/bundle/contentbundle.py b/src/sugar/bundle/contentbundle.py
    index d00936a..2d19417 100644
    a b class ContentBundle(Bundle): 
    5454        self._library_version = None
    5555        self._bundle_class = None
    5656        self._activity_start = None
     57        self._global_name = None
    5758
    5859        info_file = self.get_file('library/library.info')
    5960        if info_file is None:
    class ContentBundle(Bundle): 
    126127            raise MalformedBundleException(
    127128                'Content bundle %s does not specify a category' % self._path)
    128129
     130        if cp.has_option(section, 'global_name'):
     131            self._global_name = cp.get(section, 'global_name')
     132        else:
     133            self._global_name = None
     134
    129135        if cp.has_option(section, 'category_icon'):
    130136            self._category_icon = cp.get(section, 'category_icon')
    131137        else:
    class ContentBundle(Bundle): 
    151157        else:
    152158            self._activity_start = 'index.html'
    153159
     160        if self._bundle_class is None and self._global_name is None:
     161            raise MalformedBundleException(
     162                'Content bundle %s must specify either global_name or '
     163                'bundle_class' % self._path)
     164
    154165    def get_name(self):
    155166        return self._name
    156167
    class ContentBundle(Bundle): 
    201212    # TODO treat ContentBundle in special way
    202213    # needs rethinking while fixing ContentBundle support
    203214    def get_bundle_id(self):
    204         return self._bundle_class
     215        if self._bundle_class is not None:
     216            return self._bundle_class
     217        else:
     218            return self._global_name
    205219
    206220    # TODO treat ContentBundle in special way
    207221    # needs rethinking while fixing ContentBundle support