]> git.decadent.org.uk Git - dak.git/commitdiff
allow querying on dm_upload_allowed
authorMark Hymers <mhy@debian.org>
Sat, 23 May 2009 23:03:47 +0000 (00:03 +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 537f822d65a445493e0515d1581ca74dd2da51aa..b3811a1afdd7e945448c0dc220cf59e3eed3fa8f 100755 (executable)
@@ -777,13 +777,17 @@ class DBSource(object):
 
 __all__.append('DBSource')
 
-def get_sources_from_name(source, session=None):
+def get_sources_from_name(source, dm_upload_allowed=None, session=None):
     """
     Returns list of DBSource objects for given C{source} name
 
     @type source: str
     @param source: DBSource package name to search for
 
+    @type dm_upload_allowed: bool
+    @param dm_upload_allowed: If None, no effect.  If True or False, only
+    return packages with that dm_upload_allowed setting
+
     @type session: Session
     @param session: Optional SQL session object (a temporary one will be
     generated if not supplied)
@@ -793,7 +797,12 @@ def get_sources_from_name(source, session=None):
     """
     if session is None:
         session = DBConn().session()
-    return session.query(DBSource).filter_by(source=source).all()
+
+    q = session.query(DBSource).filter_by(source=source)
+    if dm_upload_allowed is not None:
+        q = q.filter_by(dm_upload_allowed=dm_upload_allowed)
+
+    return q.all()
 
 __all__.append('get_sources_from_name')