Mercurial > libervia-pubsub
diff idavoll/memory_storage.py @ 146:b4490bdc77e5
Change semantics of Node.is_subscribed() to match all subscriptions for an
entity (all resources).
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Fri, 29 Jul 2005 15:33:43 +0000 |
parents | f393bccec4bc |
children | b03e5ad81173 |
line wrap: on
line diff
--- a/idavoll/memory_storage.py Thu Jul 14 20:51:48 2005 +0000 +++ b/idavoll/memory_storage.py Fri Jul 29 15:33:43 2005 +0000 @@ -128,13 +128,13 @@ return defer.succeed(subscribers) - def is_subscribed(self, subscriber): - try: - subscription = self._subscriptions[subscriber.full()] - except KeyError: - return defer.succeed(False) - - return defer.succeed(subscription.state == 'subscribed') + def is_subscribed(self, entity): + for subscriber, subscription in self._subscriptions.iteritems(): + if jid.JID(subscriber).userhost() == entity.userhost() and \ + subscription.state == 'subscribed': + return defer.succeed(True) + + return defer.succeed(False) def get_affiliations(self): affiliations = [(jid.JID(entity), affiliation) for entity, affiliation @@ -142,13 +142,11 @@ return defer.succeed(affiliations) -class LeafNode(Node): +class LeafNodeMixin: - implements(storage.ILeafNode) type = 'leaf' - def __init__(self, node_id, owner, config): - Node.__init__(self, node_id, owner, config) + def __init__(self): self._items = {} self._itemlist = [] @@ -205,6 +203,14 @@ return defer.succeed(None) +class LeafNode(Node, LeafNodeMixin): + + implements(storage.ILeafNode) + + def __init__(self, node_id, owner, config): + Node.__init__(self, node_id, owner, config) + LeafNodeMixin.__init__(self) + class Subscription: implements(storage.ISubscription)