Mercurial > libervia-pubsub
comparison idavoll/pgsql_storage.py @ 145:f393bccec4bc
Add get_affiliations to Node class in storage facilities in preparation of
support for 'Modifying Entity Affiliations' in the JEP-0060 specification.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Thu, 14 Jul 2005 20:51:48 +0000 |
parents | 812300cdbc22 |
children | b4490bdc77e5 |
comparison
equal
deleted
inserted
replaced
144:5b0b3f013ccc | 145:f393bccec4bc |
---|---|
278 resource, | 278 resource, |
279 self.id)) | 279 self.id)) |
280 | 280 |
281 return cursor.fetchone() is not None | 281 return cursor.fetchone() is not None |
282 | 282 |
283 def get_affiliations(self): | |
284 return self._dbpool.runInteraction(self._get_affiliations) | |
285 | |
286 def _get_affiliations(self, cursor): | |
287 self._check_node_exists(cursor) | |
288 | |
289 cursor.execute("""SELECT jid, affiliation FROM nodes | |
290 JOIN affiliations ON | |
291 (nodes.id = affiliations.node_id) | |
292 JOIN entities ON | |
293 (affiliations.entity_id = entities.id) | |
294 WHERE node=%s""", | |
295 self.id) | |
296 result = cursor.fetchall() | |
297 | |
298 return [(jid.JID(r[0]), r[1]) for r in result] | |
299 | |
283 class LeafNode(Node): | 300 class LeafNode(Node): |
284 | 301 |
285 implements(storage.ILeafNode) | 302 implements(storage.ILeafNode) |
286 | 303 |
287 type = 'leaf' | 304 type = 'leaf' |
376 self._check_node_exists(cursor) | 393 self._check_node_exists(cursor) |
377 | 394 |
378 cursor.execute("""DELETE FROM items WHERE | 395 cursor.execute("""DELETE FROM items WHERE |
379 node_id=(SELECT id FROM nodes WHERE node=%s)""", | 396 node_id=(SELECT id FROM nodes WHERE node=%s)""", |
380 (self.id,)) | 397 (self.id,)) |
381 |