From d2fba30d9addbeb02fa86c2f7a9e59f62f30485b Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Thu, 09 Jul 2009 11:41:05 +0000 Subject: 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). --- diff --git a/src/sugar/bundle/contentbundle.py b/src/sugar/bundle/contentbundle.py index d00936a..2d19417 100644 --- a/src/sugar/bundle/contentbundle.py +++ b/src/sugar/bundle/contentbundle.py @@ -54,6 +54,7 @@ class ContentBundle(Bundle): self._library_version = None self._bundle_class = None self._activity_start = None + self._global_name = None info_file = self.get_file('library/library.info') if info_file is None: @@ -126,6 +127,11 @@ class ContentBundle(Bundle): raise MalformedBundleException( 'Content bundle %s does not specify a category' % self._path) + if cp.has_option(section, 'global_name'): + self._global_name = cp.get(section, 'global_name') + else: + self._global_name = None + if cp.has_option(section, 'category_icon'): self._category_icon = cp.get(section, 'category_icon') else: @@ -151,6 +157,11 @@ class ContentBundle(Bundle): else: self._activity_start = 'index.html' + if self._bundle_class is None and self._global_name is None: + raise MalformedBundleException( + 'Content bundle %s must specify either global_name or ' + 'bundle_class' % self._path) + def get_name(self): return self._name @@ -201,7 +212,10 @@ class ContentBundle(Bundle): # TODO treat ContentBundle in special way # needs rethinking while fixing ContentBundle support def get_bundle_id(self): - return self._bundle_class + if self._bundle_class is not None: + return self._bundle_class + else: + return self._global_name # TODO treat ContentBundle in special way # needs rethinking while fixing ContentBundle support -- cgit v0.9.1