Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2012-08-17 23:13:15 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2012-08-17 23:13:15 (GMT)
commitc4e2db0e1ce5e393efce346d3531452cd0bec9be (patch)
tree24e7a46597e62805473f69cb454baf3a30802144
parentc4e3720d867fe8fdcd8ca989e64b4d78052c5629 (diff)
If online activites were requested, keep them for offline using
-rw-r--r--plugin/bundleregistry.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/plugin/bundleregistry.py b/plugin/bundleregistry.py
index dbff344..324921f 100644
--- a/plugin/bundleregistry.py
+++ b/plugin/bundleregistry.py
@@ -21,6 +21,7 @@ from gettext import gettext as _
import gtk
import gobject
+from pylru import lrucache
from sugar_network import checkins, sugar
from sugar.bundle.activitybundle import ActivityBundle
@@ -34,6 +35,7 @@ from jarabe.journal.journalentrybundle import JournalEntryBundle
_logger = logging.getLogger('plugins.sn.bundleregistry')
_stub_icon_path = None
+_online_cache = lrucache(32)
class BundleRegistry(gobject.GObject):
@@ -72,17 +74,23 @@ class BundleRegistry(gobject.GObject):
return self._bundles[context_guid]
if mountpoint == '~':
+ if context_guid in _online_cache:
+ return _online_cache[context_guid]
return None
+
try:
props = get_client().Get(mountpoint, 'context', context_guid,
['guid', 'keep', 'keep_impl', 'title'])
- result = _ContextInfo(mountpoint, props)
+ bundle = _ContextInfo(mountpoint, props)
except Exception:
_logger.warning('Cannot fetch activity metadata for %r on %r',
context_guid, mountpoint)
- result = None
+ bundle = None
- return result
+ # Keep even None budles to avoid needless retrying
+ _online_cache[context_guid] = bundle
+
+ return bundle
def get_activities_for_type(self, mime_type):
result = []