From 32526b9cafff9b9ab3cfae177e634b7f4b43dcc3 Mon Sep 17 00:00:00 2001 From: Mark Hymers Date: Sat, 23 May 2009 22:57:56 +0100 Subject: [PATCH] add get_uid_from_fingerprint routine Signed-off-by: Mark Hymers --- daklib/dbconn.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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): -- 2.39.5