diff options
author | Daniel Drake <dsd@laptop.org> | 2009-07-09 11:41:05 (GMT) |
---|---|---|
committer | Daniel Drake <dsd@laptop.org> | 2009-07-10 17:58:42 (GMT) |
commit | d2fba30d9addbeb02fa86c2f7a9e59f62f30485b (patch) | |
tree | 91e4d8bfd07a10756d6bf08fc13faf805b738fde | |
parent | a41218b88d3ec9fa557509c4657a0173f6fbf959 (diff) |
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).
-rw-r--r-- | 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/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 |