zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #02681
[Merge] lp:~seif/zeitgeist/fix-693861 into lp:zeitgeist
Seif Lotfy has proposed merging lp:~seif/zeitgeist/fix-693861 into lp:zeitgeist.
Requested reviews:
Zeitgeist Framework Team (zeitgeist)
Related bugs:
#693861 add a getExtensions method
https://bugs.launchpad.net/bugs/693861
For more details, see:
https://code.launchpad.net/~seif/zeitgeist/fix-693861/+merge/44683
Added a get_extensions method to the API since it is very useful for client applications to know if any specific extensions are loaded or not
--
https://code.launchpad.net/~seif/zeitgeist/fix-693861/+merge/44683
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~seif/zeitgeist/fix-693861 into lp:zeitgeist.
=== modified file '_zeitgeist/engine/main.py'
--- _zeitgeist/engine/main.py 2010-11-29 09:09:13 +0000
+++ _zeitgeist/engine/main.py 2010-12-24 23:14:52 +0000
@@ -617,3 +617,6 @@
else:
log.debug("Tried to delete non-existing event(s): %s" % map(int, ids))
return None
+
+ def get_extensions(self):
+ return [extension.__class__.__name__ for extension in self.extensions]
=== modified file '_zeitgeist/engine/remote.py'
--- _zeitgeist/engine/remote.py 2010-11-01 08:25:01 +0000
+++ _zeitgeist/engine/remote.py 2010-12-24 23:14:52 +0000
@@ -348,6 +348,14 @@
self._engine.close()
if self._mainloop:
self._mainloop.quit()
+
+ @dbus.service.method(constants.DBUS_INTERFACE, in_signature="", out_signature="as")
+ def GetExtensions(self):
+ """Get all loaded extensions
+
+ This method is used to retireve all extensions loaded by zeitgeist.
+ """
+ return self._engine.get_extensions()
# Properties interface
=== modified file 'test/engine-extension-test.py'
--- test/engine-extension-test.py 2010-09-21 09:17:41 +0000
+++ test/engine-extension-test.py 2010-12-24 23:14:52 +0000
@@ -93,6 +93,9 @@
self.engine.extensions.load(BlockAllInsertExtension)
ids = import_events("test/data/five_events.js", self.engine)
+ extensions = self.engine.get_extensions()
+ self.assertEquals(extensions, ["BlockAllInsertExtension"])
+
# all but the first one events are blocked
self.assertEquals(filter(None, ids), [1])
self.assertEquals(BlockAllInsertExtension.insert_count, 1)
@@ -114,6 +117,9 @@
self.engine.extensions.load(DeleteAllInsertExtension)
ids = import_events("test/data/five_events.js", self.engine)
+ extensions = self.engine.get_extensions()
+ self.assertEquals(extensions, ["DeleteAllInsertExtension"])
+
# we try to delete the first two events, but the engine will
# block the deletion of the seconds one
self.engine.delete_events(ids[:2])
@@ -133,6 +139,9 @@
self.engine.extensions.load(BlockGetExtension)
ids = import_events("test/data/five_events.js", self.engine)
+ extensions = self.engine.get_extensions()
+ self.assertEquals(extensions, ["BlockGetExtension"])
+
# request all events, but only the first event object
# will be returned, the other events are blocked by the extension
# and presented as `None`
=== modified file 'zeitgeist/client.py'
--- zeitgeist/client.py 2010-12-14 22:02:57 +0000
+++ zeitgeist/client.py 2010-12-24 23:14:52 +0000
@@ -867,6 +867,12 @@
event_templates,
reply_handler=self._void_reply_handler,
error_handler=self._void_reply_handler) # Errors are ignored
+
+ def get_extensions(self):
+ """
+ Get the names of each :class:`Extensions` loaded by the engine
+ """
+ return self._iface.GetExtensions()
def _check_list_or_tuple(self, collection):
"""