X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=58ad0412232a78f18c01012c1ab5b9b5ba305cb5;hb=391f5ec09a119131dc846b796ca791f4cecc69e4;hp=a599e5c1cf1c96fb63498f19e2ff55cb77677666;hpb=05c66ff1004719368eb7dc54a4db1d632e8930a1;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py old mode 100644 new mode 100755 index a599e5c1..58ad0412 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -109,11 +109,11 @@ class DebVersion(UserDefinedType): return None sa_major_version = sqlalchemy.__version__[0:3] -if sa_major_version in ["0.5", "0.6", "0.7", "0.8", "0.9"]: +if sa_major_version in ["0.5", "0.6", "0.7", "0.8", "0.9", "1.0"]: from sqlalchemy.databases import postgres postgres.ischema_names['debversion'] = DebVersion else: - raise Exception("dak only ported to SQLA versions 0.5 to 0.9. See daklib/dbconn.py") + raise Exception("dak only ported to SQLA versions 0.5 to 1.0 (%s installed). See daklib/dbconn.py" % sa_major_version) ################################################################################ @@ -691,6 +691,16 @@ def get_component(component, session=None): __all__.append('get_component') +def get_mapped_component_name(component_name): + cnf = Config() + for m in cnf.value_list("ComponentMappings"): + (src, dst) = m.split() + if component_name == src: + component_name = dst + return component_name + +__all__.append('get_mapped_component_name') + @session_wrapper def get_mapped_component(component_name, session=None): """get component after mappings @@ -709,11 +719,7 @@ def get_mapped_component(component_name, session=None): @rtype: L{daklib.dbconn.Component} or C{None} @return: component after applying maps or C{None} """ - cnf = Config() - for m in cnf.value_list("ComponentMappings"): - (src, dst) = m.split() - if component_name == src: - component_name = dst + component_name = get_mapped_component_name(component_name) component = session.query(Component).filter_by(component_name=component_name).first() return component @@ -1025,7 +1031,7 @@ class Keyring(object): l.simple_bind_s("","") Attrs = l.search_s(LDAPDn, ldap.SCOPE_ONELEVEL, - "(&(keyfingerprint=*)(gidnumber=%s))" % (cnf["Import-Users-From-Passwd::ValidGID"]), + "(&(keyfingerprint=*)(supplementaryGid=%s))" % (cnf["Import-Users-From-Passwd::ValidGID"]), ["uid", "keyfingerprint", "cn", "mn", "sn"]) ldap_fin_uid_id = {} @@ -1715,7 +1721,7 @@ class DBSource(ORMObject): 'install_date', 'binaries_count', 'uploaders_count'] def not_null_constraints(self): - return ['source', 'version', 'install_date', 'maintainer', \ + return ['source', 'version', 'maintainer', \ 'changedby', 'poolfile'] def read_control_fields(self): @@ -1942,6 +1948,9 @@ class Suite(ORMObject): else: return object_session(self).query(Suite).filter_by(suite_name=self.overridesuite).one() + def update_last_changed(self): + self.last_changed = sqlalchemy.func.now() + @property def path(self): return os.path.join(self.archive.path, 'dists', self.suite_name) @@ -2152,7 +2161,8 @@ class BinaryMetadata(ORMObject): def __init__(self, key = None, value = None, binary = None): self.key = key self.value = value - self.binary = binary + if binary is not None: + self.binary = binary def properties(self): return ['binary', 'key', 'value'] @@ -2168,7 +2178,8 @@ class SourceMetadata(ORMObject): def __init__(self, key = None, value = None, source = None): self.key = key self.value = value - self.source = source + if source is not None: + self.source = source def properties(self): return ['source', 'key', 'value'] @@ -2542,6 +2553,7 @@ class DBConn(object): properties = dict(suite_id = self.tbl_suite.c.id, policy_queue = relation(PolicyQueue, primaryjoin=(self.tbl_suite.c.policy_queue_id == self.tbl_policy_queue.c.id)), new_queue = relation(PolicyQueue, primaryjoin=(self.tbl_suite.c.new_queue_id == self.tbl_policy_queue.c.id)), + debug_suite = relation(Suite, remote_side=[self.tbl_suite.c.id]), copy_queues = relation(BuildQueue, secondary=self.tbl_suite_build_queue_copy), srcformats = relation(SrcFormat, secondary=self.tbl_suite_src_formats,