Mercurial > libervia-pubsub
diff idavoll/generic_backend.py @ 118:7d83fe9bdb65
Change storage.INode.add_subscription() to return a Failure when a subscription
already exists.
Added storage.INode.get_subscription() for retrieving the subscription state.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Tue, 12 Apr 2005 12:15:44 +0000 |
parents | d252d793f0ed |
children | 43102fecb14b |
line wrap: on
line diff
--- a/idavoll/generic_backend.py Fri Apr 08 21:00:22 2005 +0000 +++ b/idavoll/generic_backend.py Tue Apr 12 12:15:44 2005 +0000 @@ -153,12 +153,19 @@ raise backend.NotAuthorized d = node.add_subscription(subscriber, 'subscribed') - d.addCallback(self._return_subscription, affiliation) + d.addCallback(lambda _: 'subscribed') + d.addErrback(self._get_subscription, node) + d.addCallback(self._return_subscription, affiliation, node.id) return d - def _return_subscription(self, result, affiliation): - result['affiliation'] = affiliation - return result + def _get_subscription(self, failure, node): + failure.Trap(storage.SubscriptionExists) + return node.get_subscription(subscriber) + + def _return_subscription(self, result, affiliation, node_id): + return {'affiliation': affiliation, + 'node': node_id, + 'state': result} def unsubscribe(self, node_id, subscriber, requestor): if subscriber.userhostJID() != requestor: