summaryrefslogtreecommitdiff
path: root/portato/db/database.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2010-03-05 01:51:35 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2010-03-05 01:51:35 +0100
commitbb95009b602311c280b4649aa6615099ceca11c0 (patch)
tree593bd7ae35fcae7114346c1dac09a1ac41a51ec0 /portato/db/database.py
parent49a7533e65d6f6904d76ec417dc1611514d5e57a (diff)
downloadportato-bb95009b602311c280b4649aa6615099ceca11c0.tar.gz
portato-bb95009b602311c280b4649aa6615099ceca11c0.tar.bz2
portato-bb95009b602311c280b4649aa6615099ceca11c0.zip
Add description support to the databases
Diffstat (limited to '')
-rw-r--r--portato/db/database.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/portato/db/database.py b/portato/db/database.py
index 7a23e5e..67ac554 100644
--- a/portato/db/database.py
+++ b/portato/db/database.py
@@ -14,6 +14,10 @@ from __future__ import absolute_import, with_statement
from threading import RLock
from functools import wraps
+from ..helper import error
+
+class UnsupportedSearchTypeError(Exception):
+ pass
class PkgData (object):
__slots__ = ("cat", "pkg", "inst", "disabled")
@@ -37,8 +41,12 @@ class Database (object):
ALL = _("ALL")
+ SEARCH_NAME = 1
+ SEARCH_DESCRIPTION = 2
+
def __init__ (self):
self._lock = RLock()
+ self.type = self.SEARCH_NAME
@staticmethod
def lock (f):
@@ -51,6 +59,25 @@ class Database (object):
return wrapper
+ def search_types (self):
+ """The types of search supported by the database.
+
+ @return: type
+ @rtype: int"""
+ raise NotImplentedError
+
+ def set_type (self, type):
+ if type & self.search_types() == 0:
+ error("Search type %s not supported by database '%s'.", type, self.__class__.__name__)
+ raise UnsupportedSearchTypeError, type
+
+ self._type = type
+
+ def get_type (self):
+ return self._type
+
+ type = property(get_type, set_type)
+
def populate (self, category = None):
"""Populates the database.