Mercurial > libervia-pubsub
comparison idavoll/pgsql_backend.py @ 62:8cdbc27c467a
Add get_affiliations() and get_subscriptions() to Storage.
Add AffiliationsService as a subclass of backend.AffiliationsService.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Sat, 06 Nov 2004 21:03:31 +0000 |
parents | 0fa161c00ed9 |
children | 13ced084aa69 |
comparison
equal
deleted
inserted
replaced
61:ad08e021b4d5 | 62:8cdbc27c467a |
---|---|
189 except Exception, e: | 189 except Exception, e: |
190 print e | 190 print e |
191 | 191 |
192 return None | 192 return None |
193 | 193 |
194 def get_affiliations(self, entity): | |
195 return self.dbpool.runQuery("""SELECT node, affiliation FROM entities | |
196 JOIN affiliations ON | |
197 (affiliations.entity_id=entities.id) | |
198 JOIN nodes ON | |
199 (nodes.id=affiliations.node_id) | |
200 WHERE jid=%s""", | |
201 (entity.full().encode('utf8'),)) | |
202 | |
203 def get_subscriptions(self, entity): | |
204 d = self.dbpool.runQuery("""SELECT node, jid, resource, subscription | |
205 FROM entities JOIN subscriptions ON | |
206 (subscriptions.entity_id=entities.id) | |
207 JOIN nodes ON | |
208 (nodes.id=subscriptions.node_id) | |
209 WHERE jid=%s""", | |
210 (entity.full().encode('utf8'),)) | |
211 d.addCallback(self._convert_subscription_jids) | |
212 return d | |
213 | |
214 def _convert_subscription_jids(self, subscriptions): | |
215 return [(node, jid.JID('%s/%s' % (subscriber, resource)), subscription) | |
216 for node, subscriber, resource, subscription in subscriptions] | |
194 | 217 |
195 class BackendService(backend.BackendService): | 218 class BackendService(backend.BackendService): |
196 """ PostgreSQL backend Service for a JEP-0060 pubsub service """ | 219 """ PostgreSQL backend Service for a JEP-0060 pubsub service """ |
197 | 220 |
198 class NodeCreationService(backend.NodeCreationService): | 221 class NodeCreationService(backend.NodeCreationService): |
204 class NotificationService(backend.NotificationService): | 227 class NotificationService(backend.NotificationService): |
205 pass | 228 pass |
206 | 229 |
207 class SubscriptionService(backend.SubscriptionService): | 230 class SubscriptionService(backend.SubscriptionService): |
208 pass | 231 pass |
232 | |
233 class AffiliationsService(backend.AffiliationsService): | |
234 pass |