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-13 21:36:14 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2012-08-13 21:36:14 (GMT)
commit2ba87be3b9592074efed64ddb81c9b3ed668ca22 (patch)
tree41a81e7fdcb0f7e2afb1a70a5b8066891f12fb67
parent92be8a8f829b082003076f6b328c5277bd0d4b6d (diff)
Update activities list on db population
-rw-r--r--plugin/bundleregistry.py39
1 files changed, 23 insertions, 16 deletions
diff --git a/plugin/bundleregistry.py b/plugin/bundleregistry.py
index 3f9bb36..d20329f 100644
--- a/plugin/bundleregistry.py
+++ b/plugin/bundleregistry.py
@@ -48,22 +48,8 @@ class BundleRegistry(gobject.GObject):
self._bundles = {}
def populate(self):
- client = get_client()
- client.connect_to_signal('Event', self.__Event_cb)
-
- def reply_handler(entries, total):
- for props in entries:
- bundle = self._add_bundle(props['guid'], props)
- if bundle is not None:
- self.emit('bundle-added', bundle)
-
- def error_handler(error):
- _logger.warning('Cannot call Find(): %s', error)
-
- client.Find('~', 'context',
- ['guid', 'keep', 'keep_impl', 'position'],
- {'keep_impl': 2, 'limit': 1024},
- reply_handler=reply_handler, error_handler=error_handler)
+ get_client().connect_to_signal('Event', self.__Event_cb)
+ self._populate()
def __iter__(self):
return self._bundles.itervalues()
@@ -146,6 +132,25 @@ class BundleRegistry(gobject.GObject):
def upgrade(self, bundle):
raise NotImplementedError('Not yet supported')
+ def _populate(self):
+
+ def reply_handler(entries, total):
+ for props in entries:
+ if props['guid'] in self._bundles:
+ continue
+ bundle = self._add_bundle(props['guid'], props)
+ if bundle is not None:
+ self.emit('bundle-added', bundle)
+
+ def error_handler(error):
+ _logger.warning('Cannot call Find(): %s', error)
+
+ get_client().Find('~', 'context',
+ ['guid', 'keep', 'keep_impl', 'position'],
+ # TODO process result by portions less than 1024
+ {'keep_impl': 2, 'limit': 1024},
+ reply_handler=reply_handler, error_handler=error_handler)
+
def _add_bundle(self, bundle_id, props):
for path in checkins(bundle_id):
try:
@@ -195,6 +200,8 @@ class BundleRegistry(gobject.GObject):
elif event_type == 'delete':
bundle_id = event['guid']
self._set_keep_impl(bundle_id, 0)
+ elif event_type == 'populate':
+ self._populate()
class _ContextInfo(object):