Mercurial > libervia-pubsub
comparison 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 |
comparison
equal
deleted
inserted
replaced
145:f393bccec4bc | 146:b4490bdc77e5 |
---|---|
126 in self._subscriptions.iteritems() | 126 in self._subscriptions.iteritems() |
127 if subscription.state == 'subscribed'] | 127 if subscription.state == 'subscribed'] |
128 | 128 |
129 return defer.succeed(subscribers) | 129 return defer.succeed(subscribers) |
130 | 130 |
131 def is_subscribed(self, subscriber): | 131 def is_subscribed(self, entity): |
132 try: | 132 for subscriber, subscription in self._subscriptions.iteritems(): |
133 subscription = self._subscriptions[subscriber.full()] | 133 if jid.JID(subscriber).userhost() == entity.userhost() and \ |
134 except KeyError: | 134 subscription.state == 'subscribed': |
135 return defer.succeed(False) | 135 return defer.succeed(True) |
136 | 136 |
137 return defer.succeed(subscription.state == 'subscribed') | 137 return defer.succeed(False) |
138 | 138 |
139 def get_affiliations(self): | 139 def get_affiliations(self): |
140 affiliations = [(jid.JID(entity), affiliation) for entity, affiliation | 140 affiliations = [(jid.JID(entity), affiliation) for entity, affiliation |
141 in self._affiliations.iteritems()] | 141 in self._affiliations.iteritems()] |
142 | 142 |
143 return defer.succeed(affiliations) | 143 return defer.succeed(affiliations) |
144 | 144 |
145 class LeafNode(Node): | 145 class LeafNodeMixin: |
146 | 146 |
147 implements(storage.ILeafNode) | |
148 type = 'leaf' | 147 type = 'leaf' |
149 | 148 |
150 def __init__(self, node_id, owner, config): | 149 def __init__(self): |
151 Node.__init__(self, node_id, owner, config) | |
152 self._items = {} | 150 self._items = {} |
153 self._itemlist = [] | 151 self._itemlist = [] |
154 | 152 |
155 def store_items(self, items, publisher): | 153 def store_items(self, items, publisher): |
156 for data in items: | 154 for data in items: |
203 self._items = {} | 201 self._items = {} |
204 self._itemlist = [] | 202 self._itemlist = [] |
205 | 203 |
206 return defer.succeed(None) | 204 return defer.succeed(None) |
207 | 205 |
206 class LeafNode(Node, LeafNodeMixin): | |
207 | |
208 implements(storage.ILeafNode) | |
209 | |
210 def __init__(self, node_id, owner, config): | |
211 Node.__init__(self, node_id, owner, config) | |
212 LeafNodeMixin.__init__(self) | |
213 | |
208 class Subscription: | 214 class Subscription: |
209 | 215 |
210 implements(storage.ISubscription) | 216 implements(storage.ISubscription) |
211 | 217 |
212 def __init__(self, state): | 218 def __init__(self, state): |