Mercurial > libervia-pubsub
comparison idavoll/pgsql_backend.py @ 95:3ad74552bbc7
Merge from RELENG_0: Implemented node configuration.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Tue, 23 Nov 2004 16:18:52 +0000 |
parents | 59378610b16e |
children | b9c449f4c167 |
comparison
equal
deleted
inserted
replaced
94:bbebadd71d35 | 95:3ad74552bbc7 |
---|---|
21 configuration = {} | 21 configuration = {} |
22 cursor.execute("""SELECT persistent, deliver_payload FROM nodes | 22 cursor.execute("""SELECT persistent, deliver_payload FROM nodes |
23 WHERE node=%s""", | 23 WHERE node=%s""", |
24 (node_id,)) | 24 (node_id,)) |
25 try: | 25 try: |
26 (configuration["persist_items"], | 26 (configuration["pubsub#persist_items"], |
27 configuration["deliver_payloads"]) = cursor.fetchone() | 27 configuration["pubsub#deliver_payloads"]) = cursor.fetchone() |
28 return configuration | 28 return configuration |
29 except TypeError: | 29 except TypeError: |
30 raise backend.NodeNotFound | 30 raise backend.NodeNotFound |
31 | 31 |
32 def get_node_configuration(self, node_id): | 32 def get_node_configuration(self, node_id): |
326 self._check_node_exists(cursor, node_id) | 326 self._check_node_exists(cursor, node_id) |
327 | 327 |
328 cursor.execute("""DELETE FROM nodes WHERE node=%s""", | 328 cursor.execute("""DELETE FROM nodes WHERE node=%s""", |
329 (node_id.encode('utf-8'),)) | 329 (node_id.encode('utf-8'),)) |
330 | 330 |
331 def set_node_configuration(self, node_id, options): | |
332 return self.dbpool.runInteraction(self._set_node_configuration, | |
333 node_id, | |
334 options) | |
335 | |
336 def _set_node_configuration(self, cursor, node_id, options): | |
337 cursor.execute("""UPDATE nodes SET persistent=%s, deliver_payload=%s | |
338 WHERE node=%s""", | |
339 (options["pubsub#persist_items"].encode('utf8'), | |
340 options["pubsub#deliver_payloads"].encode('utf8'), | |
341 node_id.encode('utf-8'))) | |
342 if cursor.rowcount != 1: | |
343 raise backend.Error | |
344 | |
331 class BackendService(backend.BackendService): | 345 class BackendService(backend.BackendService): |
332 """ PostgreSQL backend Service for a JEP-0060 pubsub service """ | 346 """ PostgreSQL backend Service for a JEP-0060 pubsub service """ |
333 | 347 |
334 class NodeCreationService(backend.NodeCreationService): | 348 class NodeCreationService(backend.NodeCreationService): |
335 pass | 349 pass |