]> err.no Git - dak/commitdiff
Port get_maintainer to dbconn.
authorChris Lamb <lamby@debian.org>
Mon, 26 Oct 2009 13:54:02 +0000 (13:54 +0000)
committerChris Lamb <lamby@debian.org>
Mon, 26 Oct 2009 13:54:02 +0000 (13:54 +0000)
Signed-off-by: Chris Lamb <lamby@debian.org>
daklib/dbconn.py

index 556921eae2c039a2ce3d6cbe12202a47a0f9b0fb..b63b4a9380d1fed873d0031e25dd1286e08055cc 100755 (executable)
@@ -1095,6 +1095,30 @@ def get_or_set_maintainer(name, session=None):
 
 __all__.append('get_or_set_maintainer')
 
+def get_maintainer(maintainer_id, session=True):
+    """
+    Return the name of the maintainer behind C{maintainer_id}.
+
+    @type maintainer_id: int
+    @param maintainer_id: the id of the maintainer
+
+    @rtype: string
+    @return: the name of the maintainer
+    """
+
+    privatetrans = False
+    if session is None:
+        session = DBConn().session()
+        privatetrans = True
+
+    try:
+        return session.query(Maintainer).get(maintainer_id).name
+    finally:
+        if privatetrans:
+            session.close()
+
+__all__.append('get_maintainer')
+
 ################################################################################
 
 class NewComment(object):