changeset 2735:ba74914277cf

core (memory/sqlite): new delPrivateNamespace method to delete all data of a specific namespace for a profile.
author Goffi <goffi@goffi.org>
date Wed, 02 Jan 2019 18:25:55 +0100
parents 9702025f6dff
children df2bc2e704bc
files sat/memory/sqlite.py
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/sat/memory/sqlite.py	Wed Jan 02 18:24:14 2019 +0100
+++ b/sat/memory/sqlite.py	Wed Jan 02 18:25:55 2019 +0100
@@ -717,6 +717,23 @@
         d.addErrback(self._privateDataEb, u"delete", namespace, key, profile=profile)
         return d
 
+    def delPrivateNamespace(self, namespace, binary=False, profile=None):
+        """Delete all data from a private namespace
+
+        Be really cautious when you use this method, as all data with given namespace are
+        removed.
+        Params are the same as for delPrivateValue
+        """
+        table = self._getPrivateTable(binary, profile)
+        query_parts = [u"DELETE FROM", table, u"WHERE namespace=?"]
+        args = [namespace]
+        if profile is not None:
+            query_parts.append(u"AND profile_id=?")
+            args.append(self.profiles[profile])
+        d = self.dbpool.runQuery(u" ".join(query_parts), args)
+        d.addErrback(self._privateDataEb, u"delete namespace", namespace, profile=profile)
+        return d
+
     ## Files
 
     @defer.inlineCallbacks