X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=d39f8c582903b553d689da9bf508fa6104b5a729;hb=2d1714245f6df36ec2c7f2d7154b23e331f150a5;hp=ae5a9e0d21b6583712fcc5d7fd3578cb55479876;hpb=32fdda584ef9431de8dcada46d467b513e265d95;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index ae5a9e0d..d39f8c58 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -856,8 +856,8 @@ class BuildQueue(object): # Check if we have a file of this name or this ID already for f in self.queuefiles: - if f.fileid is not None and f.fileid == poolfile.file_id or \ - f.poolfile.filename == poolfile_basename: + if (f.fileid is not None and f.fileid == poolfile.file_id) or \ + (f.poolfile is not None and f.poolfile.filename == poolfile_basename): # In this case, update the BuildQueueFile entry so we # don't remove it too early f.lastused = datetime.now() @@ -1352,6 +1352,17 @@ __all__.append('get_dscfiles') ################################################################################ +class ExternalOverride(ORMObject): + def __init__(self, *args, **kwargs): + pass + + def __repr__(self): + return '' % (self.package, self.key, self.value) + +__all__.append('ExternalOverride') + +################################################################################ + class PoolFile(ORMObject): def __init__(self, filename = None, location = None, filesize = -1, \ md5sum = None): @@ -2861,6 +2872,12 @@ class Suite(ORMObject): return session.query(DBSource).filter_by(source = source). \ with_parent(self) + def get_overridesuite(self): + if self.overridesuite is None: + return self + else: + return object_session(self).query(Suite).filter_by(suite_name=self.overridesuite).one() + __all__.append('Suite') @session_wrapper @@ -3136,7 +3153,9 @@ __all__.append('VersionCheck') def get_version_checks(suite_name, check = None, session = None): suite = get_suite(suite_name, session) if not suite: - return None + # Make sure that what we return is iterable so that list comprehensions + # involving this don't cause a traceback + return [] q = session.query(VersionCheck).filter_by(suite=suite) if check: q = q.filter_by(check=check) @@ -3184,6 +3203,7 @@ class DBConn(object): 'changes_pending_source_files', 'changes_pool_files', 'dsc_files', + 'external_overrides', 'extra_src_references', 'files', 'fingerprint', @@ -3219,7 +3239,6 @@ class DBConn(object): 'almost_obsolete_all_associations', 'almost_obsolete_src_associations', 'any_associations_source', - 'bin_assoc_by_arch', 'bin_associations_binaries', 'binaries_suite_arch', 'binfiles_suite_component_arch', @@ -3319,6 +3338,8 @@ class DBConn(object): poolfile_id = self.tbl_dsc_files.c.file, poolfile = relation(PoolFile))) + mapper(ExternalOverride, self.tbl_external_overrides) + mapper(PoolFile, self.tbl_files, properties = dict(file_id = self.tbl_files.c.id, filesize = self.tbl_files.c.size, @@ -3591,12 +3612,21 @@ class DBConn(object): self.__setupmappers() self.pid = os.getpid() - def session(self): + def session(self, work_mem = 0): + ''' + Returns a new session object. If a work_mem parameter is provided a new + transaction is started and the work_mem parameter is set for this + transaction. The work_mem parameter is measured in MB. A default value + will be used if the parameter is not set. + ''' # reinitialize DBConn in new processes if self.pid != os.getpid(): clear_mappers() self.__createconn() - return self.db_smaker() + session = self.db_smaker() + if work_mem > 0: + session.execute("SET LOCAL work_mem TO '%d MB'" % work_mem) + return session __all__.append('DBConn')