diff 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
line wrap: on
line diff
--- a/idavoll/pgsql_backend.py	Tue Nov 16 12:16:04 2004 +0000
+++ b/idavoll/pgsql_backend.py	Wed Nov 17 20:43:13 2004 +0000
@@ -293,6 +293,8 @@
         return self.dbpool.runInteraction(self._remove_items, node_id, item_ids)
 
     def _remove_items(self, cursor, node_id, item_ids):
+        self._check_node_exists(cursor, node_id)
+        
         deleted = []
 
         for item_id in item_ids:
@@ -307,6 +309,25 @@
 
         return deleted
 
+    def purge_node(self, node_id):
+        return self.dbpool.runInteraction(self._purge_node, node_id)
+
+    def _purge_node(self, cursor, node_id):
+        self._check_node_exists(cursor, node_id)
+
+        cursor.execute("""DELETE FROM items WHERE
+                          node_id=(SELECT id FROM nodes WHERE node=%s)""",
+                       (node_id.encode('utf-8'),))
+
+    def delete_node(self, node_id):
+        return self.dbpool.runInteraction(self._delete_node, node_id)
+
+    def _delete_node(self, cursor, node_id):
+        self._check_node_exists(cursor, node_id)
+
+        cursor.execute("""DELETE FROM nodes WHERE node=%s""",
+                       (node_id.encode('utf-8'),))
+
 class BackendService(backend.BackendService):
     """ PostgreSQL backend Service for a JEP-0060 pubsub service """
 
@@ -330,3 +351,6 @@
 
 class RetractionService(backend.RetractionService):
     pass
+
+class NodeDeletionService(backend.NodeDeletionService):
+    pass