From: Torsten Werner Date: Fri, 18 Feb 2011 17:23:01 +0000 (+0100) Subject: Merge branch 'master' into dbtests X-Git-Tag: debian-r/squeeze~351^2~4 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a8c91601641c5ae0fee611869c2cd742195a1d9f;hp=-c;p=dak.git Merge branch 'master' into dbtests --- a8c91601641c5ae0fee611869c2cd742195a1d9f diff --combined daklib/dbconn.py index d430124a,e5db1644..7221d243 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@@ -467,11 -467,7 +467,11 @@@ __all__.append('get_archive' ################################################################################ class BinContents(ORMObject): - def properties(silf): + def __init__(self, file = None, binary = None): + self.file = file + self.binary = binary + + def properties(self): return ['file', 'binary'] __all__.append('BinContents') @@@ -911,8 -907,8 +911,8 @@@ class Component(ORMObject) return NotImplemented def properties(self): - return ['component_name', 'component_id', 'description', 'location', \ - 'meets_dfsg'] + return ['component_name', 'component_id', 'description', \ + 'location_count', 'meets_dfsg', 'overrides_count'] def not_null_constraints(self): return ['component_name'] @@@ -1873,15 -1869,12 +1873,15 @@@ __all__.append('get_override' ################################################################################ -class OverrideType(object): - def __init__(self, *args, **kwargs): - pass +class OverrideType(ORMObject): + def __init__(self, overridetype = None): + self.overridetype = overridetype - def __repr__(self): - return '' % self.overridetype + def properties(self): + return ['overridetype', 'overridetype_id', 'overrides_count'] + + def not_null_constraints(self): + return ['overridetype'] __all__.append('OverrideType') @@@ -2078,16 -2071,9 +2078,16 @@@ __all__.append('get_policy_queue_from_p ################################################################################ -class Priority(object): - def __init__(self, *args, **kwargs): - pass +class Priority(ORMObject): + def __init__(self, priority = None, level = None): + self.priority = priority + self.level = level + + def properties(self): + return ['priority', 'priority_id', 'level', 'overrides_count'] + + def not_null_constraints(self): + return ['priority', 'level'] def __eq__(self, val): if isinstance(val, str): @@@ -2101,6 -2087,9 +2101,6 @@@ # This signals to use the normal comparison operator return NotImplemented - def __repr__(self): - return '' % (self.priority, self.priority_id) - __all__.append('Priority') @session_wrapper @@@ -2152,15 -2141,9 +2152,15 @@@ __all__.append('get_priorities' ################################################################################ -class Section(object): - def __init__(self, *args, **kwargs): - pass +class Section(ORMObject): + def __init__(self, section = None): + self.section = section + + def properties(self): + return ['section', 'section_id', 'overrides_count'] + + def not_null_constraints(self): + return ['section'] def __eq__(self, val): if isinstance(val, str): @@@ -2174,6 -2157,9 +2174,6 @@@ # This signals to use the normal comparison operator return NotImplemented - def __repr__(self): - return '
' % self.section - __all__.append('Section') @session_wrapper @@@ -2291,9 -2277,9 +2291,9 @@@ def source_exists(source, source_versio maps = [ (x[1], x[2]) for x in maps if x[0] == "map" or x[0] == "silent-map" ] s = [suite] - for x in maps: - if x[1] in s and x[0] not in s: - s.append(x[0]) + for (from_, to) in maps: + if from_ in s and to not in s: + s.append(to) q = q.filter(DBSource.suites.any(Suite.suite_name.in_(s))) @@@ -2616,8 -2602,7 +2616,8 @@@ class Suite(ORMObject) self.version = version def properties(self): - return ['suite_name', 'version', 'sources_count', 'binaries_count'] + return ['suite_name', 'version', 'sources_count', 'binaries_count', \ + 'overrides_count'] def not_null_constraints(self): return ['suite_name', 'version'] @@@ -2887,9 -2872,7 +2887,9 @@@ class DBConn(object) 'binary_acl', 'binary_acl_map', 'build_queue', + 'build_queue_files', 'changelogs_text', + 'changes', 'component', 'config', 'changes_pending_binaries', @@@ -2916,6 -2899,11 +2916,6 @@@ 'suite', 'uid', 'upload_blocks', - # The following tables have primary keys but sqlalchemy - # version 0.5 fails to reflect them correctly with database - # versions before upgrade #41. - 'changes', - 'build_queue_files', ) tables_no_primary = ( @@@ -2928,6 -2916,9 +2928,6 @@@ 'suite_src_formats', 'suite_build_queue_copy', 'udeb_contents', - # see the comment above - #'changes', - #'build_queue_files', ) views = ( @@@ -3145,7 -3136,8 +3145,7 @@@ mapper(Location, self.tbl_location, properties = dict(location_id = self.tbl_location.c.id, component_id = self.tbl_location.c.component, - component = relation(Component, \ - backref=backref('location', uselist = False)), + component = relation(Component, backref='location'), archive_id = self.tbl_location.c.archive, archive = relation(Archive), # FIXME: the 'type' column is old cruft and @@@ -3166,21 -3158,16 +3166,21 @@@ mapper(Override, self.tbl_override, properties = dict(suite_id = self.tbl_override.c.suite, - suite = relation(Suite), + suite = relation(Suite, \ + backref=backref('overrides', lazy='dynamic')), package = self.tbl_override.c.package, component_id = self.tbl_override.c.component, - component = relation(Component), + component = relation(Component, \ + backref=backref('overrides', lazy='dynamic')), priority_id = self.tbl_override.c.priority, - priority = relation(Priority), + priority = relation(Priority, \ + backref=backref('overrides', lazy='dynamic')), section_id = self.tbl_override.c.section, - section = relation(Section), + section = relation(Section, \ + backref=backref('overrides', lazy='dynamic')), overridetype_id = self.tbl_override.c.type, - overridetype = relation(OverrideType))) + overridetype = relation(OverrideType, \ + backref=backref('overrides', lazy='dynamic')))) mapper(OverrideType, self.tbl_override_type, properties = dict(overridetype = self.tbl_override_type.c.type,