From c9ffb9d6d68161f1063adbaecb9c1db925745c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sat, 5 Sep 2009 21:01:59 +0200 Subject: Fix an error, where a category vanishes after refreshing, using the EixSQLDatabase --- portato/db/sql.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'portato/db/sql.py') diff --git a/portato/db/sql.py b/portato/db/sql.py index e79a27d..fbc01e6 100644 --- a/portato/db/sql.py +++ b/portato/db/sql.py @@ -213,12 +213,26 @@ class SQLDatabase (Database): for cat in l: yield cat["cat"] + def generate_cat_expr (self, cat): + """ + Generates an expression from a category name to match all packages of the category. + + E.g. as SQLDatabase uses regexps internally, return cat/* + + @param cat: the category + @type cat: string + + @returns: expression + """ + + return cat+"/*" + @con def reload (self, cat = None, connection = None): if cat: connection.execute("DELETE FROM packages WHERE cat = ?", (cat,)) connection.commit() - self.populate(cat+"/*", connection = connection) + self.populate(self.generate_cat_expr(cat), connection = connection) else: connection.execute("DELETE FROM packages") connection.commit() -- cgit v1.2.3