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): |
54 | 54 | self._library_version = None |
55 | 55 | self._bundle_class = None |
56 | 56 | self._activity_start = None |
| 57 | self._global_name = None |
57 | 58 | |
58 | 59 | info_file = self.get_file('library/library.info') |
59 | 60 | if info_file is None: |
… |
… |
class ContentBundle(Bundle): |
126 | 127 | raise MalformedBundleException( |
127 | 128 | 'Content bundle %s does not specify a category' % self._path) |
128 | 129 | |
| 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 | |
129 | 135 | if cp.has_option(section, 'category_icon'): |
130 | 136 | self._category_icon = cp.get(section, 'category_icon') |
131 | 137 | else: |
… |
… |
class ContentBundle(Bundle): |
151 | 157 | else: |
152 | 158 | self._activity_start = 'index.html' |
153 | 159 | |
| 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 | |
154 | 165 | def get_name(self): |
155 | 166 | return self._name |
156 | 167 | |
… |
… |
class ContentBundle(Bundle): |
201 | 212 | # TODO treat ContentBundle in special way |
202 | 213 | # needs rethinking while fixing ContentBundle support |
203 | 214 | 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 |
205 | 219 | |
206 | 220 | # TODO treat ContentBundle in special way |
207 | 221 | # needs rethinking while fixing ContentBundle support |