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).
This commit is contained in:
parent
800bbb973a
commit
5fc5b08599
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user