comparison idavoll/pgsql_backend.py @ 90:59378610b16e

Implement node purging and node deletion.
author Ralph Meijer <ralphm@ik.nu>
date Wed, 17 Nov 2004 20:43:13 +0000
parents ec557449d1aa
children 3ad74552bbc7
comparison
equal deleted inserted replaced
89:ccf699adae5e 90:59378610b16e
291 291
292 def remove_items(self, node_id, item_ids): 292 def remove_items(self, node_id, item_ids):
293 return self.dbpool.runInteraction(self._remove_items, node_id, item_ids) 293 return self.dbpool.runInteraction(self._remove_items, node_id, item_ids)
294 294
295 def _remove_items(self, cursor, node_id, item_ids): 295 def _remove_items(self, cursor, node_id, item_ids):
296 self._check_node_exists(cursor, node_id)
297
296 deleted = [] 298 deleted = []
297 299
298 for item_id in item_ids: 300 for item_id in item_ids:
299 cursor.execute("""DELETE FROM items WHERE 301 cursor.execute("""DELETE FROM items WHERE
300 node_id=(SELECT id FROM nodes WHERE node=%s) AND 302 node_id=(SELECT id FROM nodes WHERE node=%s) AND
305 if cursor.rowcount: 307 if cursor.rowcount:
306 deleted.append(item_id) 308 deleted.append(item_id)
307 309
308 return deleted 310 return deleted
309 311
312 def purge_node(self, node_id):
313 return self.dbpool.runInteraction(self._purge_node, node_id)
314
315 def _purge_node(self, cursor, node_id):
316 self._check_node_exists(cursor, node_id)
317
318 cursor.execute("""DELETE FROM items WHERE
319 node_id=(SELECT id FROM nodes WHERE node=%s)""",
320 (node_id.encode('utf-8'),))
321
322 def delete_node(self, node_id):
323 return self.dbpool.runInteraction(self._delete_node, node_id)
324
325 def _delete_node(self, cursor, node_id):
326 self._check_node_exists(cursor, node_id)
327
328 cursor.execute("""DELETE FROM nodes WHERE node=%s""",
329 (node_id.encode('utf-8'),))
330
310 class BackendService(backend.BackendService): 331 class BackendService(backend.BackendService):
311 """ PostgreSQL backend Service for a JEP-0060 pubsub service """ 332 """ PostgreSQL backend Service for a JEP-0060 pubsub service """
312 333
313 class NodeCreationService(backend.NodeCreationService): 334 class NodeCreationService(backend.NodeCreationService):
314 pass 335 pass
328 class ItemRetrievalService(backend.ItemRetrievalService): 349 class ItemRetrievalService(backend.ItemRetrievalService):
329 pass 350 pass
330 351
331 class RetractionService(backend.RetractionService): 352 class RetractionService(backend.RetractionService):
332 pass 353 pass
354
355 class NodeDeletionService(backend.NodeDeletionService):
356 pass