]> git.decadent.org.uk Git - dak.git/commitdiff
Refactor add_dsc_to_db().
authorTorsten Werner <twerner@debian.org>
Sat, 22 Jan 2011 10:51:29 +0000 (11:51 +0100)
committerTorsten Werner <twerner@debian.org>
Sat, 22 Jan 2011 10:59:48 +0000 (11:59 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py

index 6f598bb5dd5597c061395bbceff55a6a4c8a6334..611b30a05e2fa3c922bc83926e2f9dbe723c105e 100755 (executable)
@@ -2268,12 +2268,9 @@ def add_dsc_to_db(u, filename, session=None):
     session.add(source)
     session.flush()
 
-    for suite_name in u.pkg.changes["distribution"].keys():
-        sa = SrcAssociation()
-        sa.source_id = source.source_id
-        sa.suite_id = get_suite(suite_name).suite_id
-        session.add(sa)
-
+    suite_names = u.pkg.changes["distribution"].keys()
+    source.suites = session.query(Suite). \
+        filter(Suite.suite_name.in_(suite_names)).all()
     session.flush()
 
     # Add the source files to the DB (files and dsc_files)