Mercurial > libervia-pubsub
diff idavoll/backend.py @ 85:ec557449d1aa
Implement node retraction, with storage support for pgsql.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Tue, 09 Nov 2004 16:48:20 +0000 |
parents | 34be83a0bd2e |
children | 59378610b16e |
line wrap: on
line diff
--- a/idavoll/backend.py Tue Nov 09 15:58:06 2004 +0000 +++ b/idavoll/backend.py Tue Nov 09 16:48:20 2004 +0000 @@ -346,3 +346,37 @@ return d else: return self.parent.storage.get_items(node_id, max_items) + +class RetractionService(service.Service): + + __implements__ = IRetractionService, + + def retract_item(self, node_id, item_ids, requestor): + d1 = self.parent.storage.get_node_configuration(node_id) + d2 = self.parent.storage.get_affiliation(node_id, requestor) + d = defer.DeferredList([d1, d2], fireOnOneErrback=1) + d.addErrback(lambda x: x.value[0]) + d.addCallback(self._do_retract, node_id, item_ids) + return d + + def _do_retract(self, result, node_id, item_ids): + configuration = result[0][1] + persist_items = configuration["persist_items"] + affiliation = result[1][1] + + if affiliation not in ['owner', 'publisher']: + raise NotAuthorized + + if not persist_items: + raise NodeNotPersistent + + d = self.parent.storage.remove_items(node_id, item_ids) + d.addCallback(self._do_notify_retraction, node_id) + return d + + def _do_notify_retraction(self, result, node_id): + self.parent.dispatch({ 'item_ids': result, 'node_id': node_id }, + '//event/pubsub/retract') + + def purge_node(self, node_id, requestor): + pass