]> git.decadent.org.uk Git - dak.git/commitdiff
Simplify src_format handling
authorMark Hymers <mhy@debian.org>
Sat, 30 Jul 2011 09:28:27 +0000 (10:28 +0100)
committerMark Hymers <mhy@debian.org>
Sat, 30 Jul 2011 09:28:27 +0000 (10:28 +0100)
Signed-off-by: Mark Hymers <mhy@debian.org>
dak/admin.py
daklib/dbconn.py
daklib/queue.py

index 5f0dcc9eeda8848c22ddb4b5536bd7bd647900e7..60c4bc6d4556e216c8da45fdec4f549cfcba3546 100755 (executable)
@@ -224,14 +224,9 @@ def __suite_add(d, args, addallarches=False):
             signingkey = get_field('signingkey')
             if signingkey is not None:
                 suite.signingkeys = [signingkey.upper()]
+            suite.srcformats = s.query(SrcFormat).all()
             s.add(suite)
             s.flush()
-            for sf in s.query(SrcFormat).all():
-                ssf = SuiteSrcFormat()
-                ssf.suite = suite
-                ssf.src_format = sf
-                s.add(ssf)
-                s.flush()
         except IntegrityError, e:
             die("E: Integrity error adding suite %s (it probably already exists)" % suite_name)
         except SQLAlchemyError, e:
index e88911c5109201ab597cd3f2ca9aba0a75dfdd6e..6d954c88884095e1aba61338917d912ddc133660 100755 (executable)
@@ -3036,42 +3036,6 @@ __all__.append('get_suite_architectures')
 
 ################################################################################
 
-class SuiteSrcFormat(object):
-    def __init__(self, *args, **kwargs):
-        pass
-
-    def __repr__(self):
-        return '<SuiteSrcFormat (%s, %s)>' % (self.suite_id, self.src_format_id)
-
-__all__.append('SuiteSrcFormat')
-
-@session_wrapper
-def get_suite_src_formats(suite, session=None):
-    """
-    Returns list of allowed SrcFormat for C{suite}.
-
-    @type suite: str
-    @param suite: Suite name to search for
-
-    @type session: Session
-    @param session: Optional SQL session object (a temporary one will be
-    generated if not supplied)
-
-    @rtype: list
-    @return: the list of allowed source formats for I{suite}
-    """
-
-    q = session.query(SrcFormat)
-    q = q.join(SuiteSrcFormat)
-    q = q.join(Suite).filter_by(suite_name=suite)
-    q = q.order_by('format_name')
-
-    return q.all()
-
-__all__.append('get_suite_src_formats')
-
-################################################################################
-
 class Uid(ORMObject):
     def __init__(self, uid = None, name = None):
         self.uid = uid
@@ -3604,15 +3568,11 @@ class DBConn(object):
                properties = dict(suite_id = self.tbl_suite.c.id,
                                  policy_queue = relation(PolicyQueue),
                                  copy_queues = relation(BuildQueue,
-                                     secondary=self.tbl_suite_build_queue_copy)),
+                                     secondary=self.tbl_suite_build_queue_copy),
+                                 srcformats = relation(SrcFormat, secondary=self.tbl_suite_src_formats,
+                                     backref=backref('suites', lazy='dynamic'))),
                 extension = validator)
 
-        mapper(SuiteSrcFormat, self.tbl_suite_src_formats,
-               properties = dict(suite_id = self.tbl_suite_src_formats.c.suite,
-                                 suite = relation(Suite, backref='suitesrcformats'),
-                                 src_format_id = self.tbl_suite_src_formats.c.src_format,
-                                 src_format = relation(SrcFormat)))
-
         mapper(Uid, self.tbl_uid,
                properties = dict(uid_id = self.tbl_uid.c.id,
                                  fingerprint = relation(Fingerprint)),
index c2f0414f6e31adb42402376a928e30787bf1405a..f912bef19aec4a97470859463e7eae627b1bf65c 100755 (executable)
@@ -1217,7 +1217,7 @@ class Upload(object):
 
         # Only a limited list of source formats are allowed in each suite
         for dist in self.pkg.changes["distribution"].keys():
-            allowed = [ x.format_name for x in get_suite_src_formats(dist, session) ]
+            allowed = [ x.format_name for x in dist.srcformats ]
             if self.pkg.dsc["format"] not in allowed:
                 self.rejects.append("%s: source format '%s' not allowed in %s (accepted: %s) " % (dsc_filename, self.pkg.dsc["format"], dist, ", ".join(allowed)))