Mercurial > libervia-pubsub
comparison idavoll/backend.py @ 92:878a5b7697f2
Consume errors in DeferredLists.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Wed, 17 Nov 2004 21:00:03 +0000 |
parents | 59378610b16e |
children | 3ad74552bbc7 |
comparison
equal
deleted
inserted
replaced
91:47ee5369c410 | 92:878a5b7697f2 |
---|---|
196 __implements__ = IPublishService, | 196 __implements__ = IPublishService, |
197 | 197 |
198 def publish(self, node_id, items, requestor): | 198 def publish(self, node_id, items, requestor): |
199 d1 = self.parent.storage.get_node_configuration(node_id) | 199 d1 = self.parent.storage.get_node_configuration(node_id) |
200 d2 = self.parent.storage.get_affiliation(node_id, requestor) | 200 d2 = self.parent.storage.get_affiliation(node_id, requestor) |
201 d = defer.DeferredList([d1, d2], fireOnOneErrback=1) | 201 d = defer.DeferredList([d1, d2], fireOnOneErrback=1, consumeErrors=1) |
202 d.addErrback(lambda x: x.value[0]) | 202 d.addErrback(lambda x: x.value[0]) |
203 d.addCallback(self._do_publish, node_id, items, requestor) | 203 d.addCallback(self._do_publish, node_id, items, requestor) |
204 return d | 204 return d |
205 | 205 |
206 def _do_publish(self, result, node_id, items, requestor): | 206 def _do_publish(self, result, node_id, items, requestor): |
268 if subscriber.userhostJID() != requestor: | 268 if subscriber.userhostJID() != requestor: |
269 raise NotAuthorized | 269 raise NotAuthorized |
270 | 270 |
271 d1 = self.parent.storage.get_node_configuration(node_id) | 271 d1 = self.parent.storage.get_node_configuration(node_id) |
272 d2 = self.parent.storage.get_affiliation(node_id, subscriber) | 272 d2 = self.parent.storage.get_affiliation(node_id, subscriber) |
273 d = defer.DeferredList([d1, d2], fireOnOneErrback=1) | 273 d = defer.DeferredList([d1, d2], fireOnOneErrback=1, consumeErrors=1) |
274 d.addErrback(lambda x: x.value[0]) | 274 d.addErrback(lambda x: x.value[0]) |
275 d.addCallback(self._do_subscribe, node_id, subscriber) | 275 d.addCallback(self._do_subscribe, node_id, subscriber) |
276 return d | 276 return d |
277 | 277 |
278 def _do_subscribe(self, result, node_id, subscriber): | 278 def _do_subscribe(self, result, node_id, subscriber): |
324 __implements__ = IAffiliationsService, | 324 __implements__ = IAffiliationsService, |
325 | 325 |
326 def get_affiliations(self, entity): | 326 def get_affiliations(self, entity): |
327 d1 = self.parent.storage.get_affiliations(entity) | 327 d1 = self.parent.storage.get_affiliations(entity) |
328 d2 = self.parent.storage.get_subscriptions(entity) | 328 d2 = self.parent.storage.get_subscriptions(entity) |
329 d = defer.DeferredList([d1, d2], fireOnOneErrback=1) | 329 d = defer.DeferredList([d1, d2], fireOnOneErrback=1, consumeErrors=1) |
330 d.addErrback(lambda x: x.value[0]) | 330 d.addErrback(lambda x: x.value[0]) |
331 d.addCallback(self._affiliations_result, entity) | 331 d.addCallback(self._affiliations_result, entity) |
332 return d | 332 return d |
333 | 333 |
334 def _affiliations_result(self, result, entity): | 334 def _affiliations_result(self, result, entity): |