summaryrefslogtreecommitdiff
path: root/portato/db/sql.py
diff options
context:
space:
mode:
Diffstat (limited to 'portato/db/sql.py')
-rw-r--r--portato/db/sql.py32
1 files changed, 24 insertions, 8 deletions
diff --git a/portato/db/sql.py b/portato/db/sql.py
index fbc01e6..f5dc257 100644
--- a/portato/db/sql.py
+++ b/portato/db/sql.py
@@ -3,7 +3,7 @@
# File: portato/db/sql.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
-# Copyright (C) 2006-2009 René 'Necoro' Neumann
+# Copyright (C) 2006-2010 René 'Necoro' Neumann
# This is free software. You may redistribute copies of it under the terms of
# the GNU General Public License version 2.
# There is NO WARRANTY, to the extent permitted by law.
@@ -34,7 +34,7 @@ from .database import Database, PkgData
class SQLDatabase (Database):
- FORMAT = "1"
+ FORMAT = "2"
FORBIDDEN = (".bzr", ".svn", ".git", "CVS", ".hg", "_darcs")
lock = Database.lock
@@ -47,6 +47,7 @@ class SQLDatabase (Database):
updateFormat = False
if "format" not in session or session["format"] != self.FORMAT:
+ debug("Need to update database format from '%s' to '%s'", session["format"], self.FORMAT)
session["format"] = self.FORMAT
updateFormat = True
@@ -61,6 +62,7 @@ class SQLDatabase (Database):
pkg_conn = sql.connect(pkgdb)
pkg_conn.row_factory = sql.Row
if pkgdb_existed and updateFormat:
+ debug("Dropping old table")
pkg_conn.execute("DROP TABLE packages")
pkg_conn.execute("""
@@ -68,6 +70,7 @@ class SQLDatabase (Database):
(
name TEXT,
cat TEXT,
+ descr TEXT DEFAULT "",
inst INTEGER,
disabled INTEGER
)""")
@@ -83,6 +86,9 @@ class SQLDatabase (Database):
pkg_conn.close()
+ def search_types(self):
+ return self.SEARCH_NAME
+
def updated (self):
changed = False
@@ -114,7 +120,7 @@ class SQLDatabase (Database):
os.remove(dbpath)
db_existed = False
- self.session["pickle"] = True # no need for a certain value
+ self.session["pickle"] = "1" # no need for a certain value
if db_existed:
debug("portdirs.db already existant")
@@ -253,12 +259,22 @@ class SQLDatabase (Database):
self._restrict = ""
else:
restrict = restrict.replace(".*","%").replace(".","_")
+ rest = ""
+
+ if self._type & self.SEARCH_NAME:
+ if "/" in restrict:
+ rest = "(name LIKE '%s%%' AND cat LIKE '%s')" % (pkg, cat)
+ else:
+ rest = "(name LIKE '%%%(restrict)s%%' OR cat LIKE '%(restrict)s%%')" % {"restrict":restrict}
- if "/" in restrict:
- cat,pkg = restrict.split("/")
- self._restrict = "AND name LIKE '%s%%' AND cat LIKE '%s'" % (pkg, cat)
- else:
- self._restrict = "AND (name LIKE '%%%(restrict)s%%' OR cat LIKE '%(restrict)s%%')" % {"restrict":restrict}
+ if self._type & self.SEARCH_DESCRIPTION:
+ r = "descr LIKE '%%%(restrict)s%%'" % {"restrict":restrict}
+ if rest:
+ rest = "(%s OR %s)" % (r, rest)
+ else:
+ rest = r
+
+ self._restrict = "AND " + rest
restrict = property(get_restrict, set_restrict)
con = staticmethod(con)