Mercurial > libervia-pubsub
comparison 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 |
comparison
equal
deleted
inserted
replaced
84:34be83a0bd2e | 85:ec557449d1aa |
---|---|
344 d.addCallback(q) | 344 d.addCallback(q) |
345 d.addErrback(q) | 345 d.addErrback(q) |
346 return d | 346 return d |
347 else: | 347 else: |
348 return self.parent.storage.get_items(node_id, max_items) | 348 return self.parent.storage.get_items(node_id, max_items) |
349 | |
350 class RetractionService(service.Service): | |
351 | |
352 __implements__ = IRetractionService, | |
353 | |
354 def retract_item(self, node_id, item_ids, requestor): | |
355 d1 = self.parent.storage.get_node_configuration(node_id) | |
356 d2 = self.parent.storage.get_affiliation(node_id, requestor) | |
357 d = defer.DeferredList([d1, d2], fireOnOneErrback=1) | |
358 d.addErrback(lambda x: x.value[0]) | |
359 d.addCallback(self._do_retract, node_id, item_ids) | |
360 return d | |
361 | |
362 def _do_retract(self, result, node_id, item_ids): | |
363 configuration = result[0][1] | |
364 persist_items = configuration["persist_items"] | |
365 affiliation = result[1][1] | |
366 | |
367 if affiliation not in ['owner', 'publisher']: | |
368 raise NotAuthorized | |
369 | |
370 if not persist_items: | |
371 raise NodeNotPersistent | |
372 | |
373 d = self.parent.storage.remove_items(node_id, item_ids) | |
374 d.addCallback(self._do_notify_retraction, node_id) | |
375 return d | |
376 | |
377 def _do_notify_retraction(self, result, node_id): | |
378 self.parent.dispatch({ 'item_ids': result, 'node_id': node_id }, | |
379 '//event/pubsub/retract') | |
380 | |
381 def purge_node(self, node_id, requestor): | |
382 pass |