]> git.decadent.org.uk Git - dak.git/commitdiff
add get_uid_from_fingerprint routine
authorMark Hymers <mhy@debian.org>
Sat, 23 May 2009 21:57:56 +0000 (22:57 +0100)
committerMark Hymers <mhy@debian.org>
Sun, 9 Aug 2009 15:49:21 +0000 (16:49 +0100)
Signed-off-by: Mark Hymers <mhy@debian.org>
daklib/dbconn.py

index cf9ca9a54c7df7d12a007c36161ff86dbfefdaa6..537f822d65a445493e0515d1581ca74dd2da51aa 100755 (executable)
@@ -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):