From cfe38485d37a03806a751988d0ef38e98fe90845 Mon Sep 17 00:00:00 2001 From: Mark Hymers Date: Sat, 30 Jul 2011 10:28:27 +0100 Subject: [PATCH] Simplify src_format handling Signed-off-by: Mark Hymers --- dak/admin.py | 7 +------ daklib/dbconn.py | 46 +++------------------------------------------- daklib/queue.py | 2 +- 3 files changed, 5 insertions(+), 50 deletions(-) diff --git a/dak/admin.py b/dak/admin.py index 5f0dcc9e..60c4bc6d 100755 --- a/dak/admin.py +++ b/dak/admin.py @@ -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: diff --git a/daklib/dbconn.py b/daklib/dbconn.py index e88911c5..6d954c88 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -3036,42 +3036,6 @@ __all__.append('get_suite_architectures') ################################################################################ -class SuiteSrcFormat(object): - def __init__(self, *args, **kwargs): - pass - - def __repr__(self): - return '' % (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)), diff --git a/daklib/queue.py b/daklib/queue.py index c2f0414f..f912bef1 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -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))) -- 2.39.5