From: Mark Hymers Date: Sat, 25 Apr 2009 14:43:31 +0000 (+0100) Subject: update to 0.5 api X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c2f95858a5329706b8ba01a29e2264bacdd4fa0;p=dak update to 0.5 api Signed-off-by: Mark Hymers --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 3a11c2a1..d0f1389b 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -139,6 +139,24 @@ def get_binary_from_id(id, session=None): return None return q.one() +def get_binaries_from_name(package, session=None): + """ + Returns list of Binary objects for given C{package} name + + @type package: str + @param package: Binary package name to search for + + @type session: Session + @param session: Optional SQL session object (a temporary one will be + generated if not supplied) + + @rtype: list + @return: list of Binary objects for the given name (may be empty) + """ + if session is None: + session = DBConn().session() + return session.query(Binary).filter_by(package=package).all() + class Component(object): def __init__(self, *args, **kwargs): pass @@ -357,6 +375,24 @@ class Source(object): def __repr__(self): return '' % (self.source, self.version) +def get_sources_from_name(source, session=None): + """ + Returns list of Source objects for given C{source} name + + @type source: str + @param source: Source package name to search for + + @type session: Session + @param session: Optional SQL session object (a temporary one will be + generated if not supplied) + + @rtype: list + @return: list of Source objects for the given name (may be empty) + """ + if session is None: + session = DBConn().session() + return session.query(Source).filter_by(source=source).all() + def get_source_in_suite(source, suite, session=None): """ Returns list of Source objects for a combination of C{source} and C{suite}. @@ -684,7 +720,7 @@ class DBConn(Singleton): self.db_meta.bind = self.db_pg self.db_smaker = sessionmaker(bind=self.db_pg, autoflush=True, - transactional=True) + autocommit=True) self.__setuptables() self.__setupmappers()