Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2008-07-16 16:48:31 (GMT)
committer Daniel Drake <dsd@laptop.org>2008-07-21 13:01:23 (GMT)
commit02d3799b54c55d7803bc933fab44cb2fde38323e (patch)
tree4d85ce4d20cbbf7e36b1d96113ee00917d74c56a /src
parent5d5f75f7e3ae9c387a6d6bb0b0ddff6f7c52c5e0 (diff)
#7532 install + open content bundles through journal
Diffstat (limited to 'src')
-rw-r--r--src/sugar/bundle/contentbundle.py24
-rw-r--r--src/sugar/datastore/datastore.py18
2 files changed, 38 insertions, 4 deletions
diff --git a/src/sugar/bundle/contentbundle.py b/src/sugar/bundle/contentbundle.py
index 38d4e51..32f38e3 100644
--- a/src/sugar/bundle/contentbundle.py
+++ b/src/sugar/bundle/contentbundle.py
@@ -19,6 +19,7 @@
from ConfigParser import ConfigParser
import os
+import urllib
from sugar import env
from sugar.bundle.bundle import Bundle, NotInstalledException, \
@@ -140,6 +141,11 @@ class ContentBundle(Bundle):
else:
self._bundle_class = None
+ if cp.has_option(section, 'activity_start'):
+ self._activity_start = cp.get(section, 'activity_start')
+ else:
+ self._activity_start = 'index.html'
+
def get_name(self):
return self._name
@@ -167,6 +173,9 @@ class ContentBundle(Bundle):
def get_bundle_class(self):
return self._bundle_class
+ def get_activity_start(self):
+ return self._activity_start
+
def _run_indexer(self):
xdg_data_dirs = os.getenv('XDG_DATA_DIRS',
'/usr/local/share/:/usr/share/')
@@ -175,11 +184,19 @@ class ContentBundle(Bundle):
if os.path.exists(indexer):
os.spawnlp(os.P_WAIT, 'python', 'python', indexer)
+ def get_root_dir(self):
+ return os.path.join(env.get_user_library_path(), self._zip_root_dir)
+
+ def get_start_path(self):
+ return os.path.join(self.get_root_dir(), self._activity_start)
+
+ def get_start_uri(self):
+ return "file://" + urllib.pathname2url(self.get_start_path())
+
def is_installed(self):
if self._unpacked:
return True
- elif os.path.isdir(os.path.join(env.get_user_library_path(),
- self._zip_root_dir)):
+ elif os.path.isdir(self.get_root_dir()):
return True
else:
return False
@@ -194,7 +211,6 @@ class ContentBundle(Bundle):
raise NotInstalledException
install_dir = self._path
else:
- install_dir = os.path.join(env.get_user_library_path(),
- self._zip_root_dir)
+ install_dir = os.path.join(self.get_root_dir())
self._uninstall(install_dir)
self._run_indexer()
diff --git a/src/sugar/datastore/datastore.py b/src/sugar/datastore/datastore.py
index b7792f4..b88a877 100644
--- a/src/sugar/datastore/datastore.py
+++ b/src/sugar/datastore/datastore.py
@@ -169,6 +169,24 @@ class DSObject(object):
logging.debug('activityfactory.creating bundle with id %r',
bundle.get_bundle_id())
activityfactory.create(bundle.get_bundle_id())
+
+ elif self.is_content_bundle() and not bundle_id:
+
+ logging.debug('Creating content bundle')
+ bundle = ContentBundle(self.file_path)
+ if not bundle.is_installed():
+ logging.debug('Installing content bundle')
+ bundle.install()
+
+ activities = self._get_activities_for_mime('text/html')
+ if len(activities) == 0:
+ logging.warning('No activity can open HTML content bundles')
+ return
+
+ uri = bundle.get_start_uri()
+ logging.debug('activityfactory.creating with uri %s', uri)
+ activityfactory.create_with_uri(activities[0].bundle_id,
+ bundle.get_start_uri())
else:
if not self.get_activities() and bundle_id is None:
logging.warning('No activity can open this object, %s.' %