From: Mark Hymers Date: Sat, 23 May 2009 21:57:56 +0000 (+0100) Subject: add get_uid_from_fingerprint routine X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32526b9cafff9b9ab3cfae177e634b7f4b43dcc3;p=dak add get_uid_from_fingerprint routine Signed-off-by: Mark Hymers --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index cf9ca9a5..537f822d 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -974,6 +974,20 @@ class Uid(object): __all__.append('Uid') +def get_uid_from_fingerprint(fpr, session=None): + if session is None: + session = DBConn().session() + + q = session.query(Uid) + q = q.join(Fingerprint).filter_by(fingerprint=fpr) + + if q.count() != 1: + return None + else: + return q.one() + +__all__.append('get_uid_from_fingerprint') + ################################################################################ class DBConn(Singleton): @@ -1194,7 +1208,8 @@ class DBConn(Singleton): architecture = relation(Architecture))) mapper(Uid, self.tbl_uid, - properties = dict(uid_id = self.tbl_uid.c.id)) + properties = dict(uid_id = self.tbl_uid.c.id, + fingerprint = relation(Fingerprint))) ## Connection functions def __createconn(self):