Add infrastructure to delete plugin data by id
authorSimo Sorce <simo@redhat.com>
Fri, 4 Apr 2014 17:26:02 +0000 (13:26 -0400)
committerSimo Sorce <simo@redhat.com>
Fri, 4 Apr 2014 17:33:09 +0000 (13:33 -0400)
Signed-off-by: Simo Sorce <simo@redhat.com>
ipsilon/util/data.py
ipsilon/util/plugin.py

index 52dfa78..7d0e0ff 100755 (executable)
@@ -396,6 +396,23 @@ class Store(object):
             if con:
                 con.close()
 
             if con:
                 con.close()
 
+    def del_datum(self, plugin, idval):
+        DELETE = "DELETE FROM %s_data WHERE id=?" % plugin
+        con = None
+        try:
+            con = sqlite3.connect(self._admin_dbname)
+            cur = con.cursor()
+            cur.execute(DELETE, (idval,))
+            con.commit()
+        except sqlite3.Error, e:
+            if con:
+                con.rollback()
+            cherrypy.log.error("Failed to delete %s data: [%s]" % (plugin, e))
+            raise
+        finally:
+            if con:
+                con.close()
+
     def wipe_data(self, plugin):
         # Try to backup old data first, just in case
         try:
     def wipe_data(self, plugin):
         # Try to backup old data first, just in case
         try:
index cdf997e..c57cb29 100755 (executable)
@@ -160,6 +160,9 @@ class PluginObject(object):
     def new_datum(self, datum):
         self._data.new_datum(self.name, datum)
 
     def new_datum(self, datum):
         self._data.new_datum(self.name, datum)
 
+    def del_datum(self, idval):
+        self._data.del_datum(self.name, idval)
+
     def wipe_config_values(self, facility):
         self._data.wipe_plugin_config(facility, self.name)
 
     def wipe_config_values(self, facility):
         self._data.wipe_plugin_config(facility, self.name)