Mercurial > libervia-pubsub
comparison idavoll/generic_backend.py @ 129:43102fecb14b
Fix some typos.
Don't expect ids of removed items back from storage, but use the list we got
ourselves.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Sun, 24 Apr 2005 17:24:35 +0000 |
parents | 7d83fe9bdb65 |
children | 812300cdbc22 |
comparison
equal
deleted
inserted
replaced
128:b27a66637a10 | 129:43102fecb14b |
---|---|
3 from twisted.words.protocols.jabber import jid | 3 from twisted.words.protocols.jabber import jid |
4 from twisted.application import service | 4 from twisted.application import service |
5 from twisted.xish import utility | 5 from twisted.xish import utility |
6 from twisted.internet import defer | 6 from twisted.internet import defer |
7 from zope.interface import implements | 7 from zope.interface import implements |
8 import backend | 8 import backend, storage |
9 | 9 |
10 def _get_affiliation(node, entity): | 10 def _get_affiliation(node, entity): |
11 d = node.get_affiliation(entity) | 11 d = node.get_affiliation(entity) |
12 d.addCallback(lambda affiliation: (node, affiliation)) | 12 d.addCallback(lambda affiliation: (node, affiliation)) |
13 return d | 13 return d |
101 d = node.store_items(items, requestor) | 101 d = node.store_items(items, requestor) |
102 else: | 102 else: |
103 d = defer.succeed(None) | 103 d = defer.succeed(None) |
104 | 104 |
105 d.addCallback(self._do_notify, node.id, items, deliver_payloads) | 105 d.addCallback(self._do_notify, node.id, items, deliver_payloads) |
106 return d | |
106 | 107 |
107 def _do_notify(self, result, node_id, items, deliver_payloads): | 108 def _do_notify(self, result, node_id, items, deliver_payloads): |
108 if items and not deliver_payloads: | 109 if items and not deliver_payloads: |
109 for item in items: | 110 for item in items: |
110 item.children = [] | 111 item.children = [] |
152 if affiliation == 'outcast': | 153 if affiliation == 'outcast': |
153 raise backend.NotAuthorized | 154 raise backend.NotAuthorized |
154 | 155 |
155 d = node.add_subscription(subscriber, 'subscribed') | 156 d = node.add_subscription(subscriber, 'subscribed') |
156 d.addCallback(lambda _: 'subscribed') | 157 d.addCallback(lambda _: 'subscribed') |
157 d.addErrback(self._get_subscription, node) | 158 d.addErrback(self._get_subscription, node, subscriber) |
158 d.addCallback(self._return_subscription, affiliation, node.id) | 159 d.addCallback(self._return_subscription, affiliation, node.id) |
159 return d | 160 return d |
160 | 161 |
161 def _get_subscription(self, failure, node): | 162 def _get_subscription(self, failure, node, subscriber): |
162 failure.Trap(storage.SubscriptionExists) | 163 failure.trap(storage.SubscriptionExists) |
163 return node.get_subscription(subscriber) | 164 return node.get_subscription(subscriber) |
164 | 165 |
165 def _return_subscription(self, result, affiliation, node_id): | 166 def _return_subscription(self, result, affiliation, node_id): |
166 return {'affiliation': affiliation, | 167 return {'affiliation': affiliation, |
167 'node': node_id, | 168 'node': node_id, |
318 | 319 |
319 if not persist_items: | 320 if not persist_items: |
320 raise backend.NodeNotPersistent | 321 raise backend.NodeNotPersistent |
321 | 322 |
322 d = node.remove_items(item_ids) | 323 d = node.remove_items(item_ids) |
323 d.addCallback(self._do_notify_retraction, node.id) | 324 d.addCallback(self._do_notify_retraction, item_ids, node.id) |
324 return d | 325 return d |
325 | 326 |
326 def _do_notify_retraction(self, result, node_id): | 327 def _do_notify_retraction(self, result, item_ids, node_id): |
327 self.parent.dispatch({ 'item_ids': result, 'node_id': node_id }, | 328 self.parent.dispatch({ 'item_ids': item_ids, 'node_id': node_id }, |
328 '//event/pubsub/retract') | 329 '//event/pubsub/retract') |
329 | 330 |
330 def purge_node(self, node_id, requestor): | 331 def purge_node(self, node_id, requestor): |
331 d = self.parent.storage.get_node(node_id) | 332 d = self.parent.storage.get_node(node_id) |
332 d.addCallback(_get_affiliation, requestor) | 333 d.addCallback(_get_affiliation, requestor) |