From: Mark Hymers Date: Sat, 23 May 2009 23:03:47 +0000 (+0100) Subject: allow querying on dm_upload_allowed X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d733acb0b123077f9c1f899130ef24ed4d74bc7a;p=dak allow querying on dm_upload_allowed Signed-off-by: Mark Hymers --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 537f822d..b3811a1a 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -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')