X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=361dcf42cfc3b1eaad30d1f3dbc72785678e8c02;hb=85285dd42f74743aafbbe8bfbaf3579a20ae6548;hp=adf119bc74f8379d05fc11b3d57e794068aa76f1;hpb=37818276a5aba97d97763420a7655d2350dad747;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index adf119bc..361dcf42 100644 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -434,7 +434,7 @@ class BuildQueue(object): pass def __repr__(self): - return '' % self.queue_name + return '' % self.queue_name def add_file_from_pool(self, poolfile): """Copies a file into the pool. Assumes that the PoolFile object is @@ -450,7 +450,7 @@ class BuildQueue(object): # In this case, update the BuildQueueFile entry so we # don't remove it too early f.lastused = datetime.now() - DBConn().session().object_session(pf).add(f) + DBConn().session().object_session(poolfile).add(f) return f # Prepare BuildQueueFile object @@ -2062,6 +2062,11 @@ def add_dsc_to_db(u, filename, session=None): poolfile = add_poolfile(filename, dentry, dsc_location_id, session) pfs.append(poolfile) files_id = poolfile.file_id + else: + poolfile = get_poolfile_by_id(files_id, session) + if poolfile is None: + utils.fubar("INTERNAL ERROR. Found no poolfile with id %d" % files_id) + pfs.append(poolfile) df.poolfile_id = files_id session.add(df) @@ -2565,8 +2570,8 @@ class DBConn(object): ) for table_name in tables: - table = Table('tbl_%s' % table_name, self.db_meta, autoload=True) - setattr(self, table_name, table) + table = Table(table_name, self.db_meta, autoload=True) + setattr(self, 'tbl_%s' % table_name, table) def __setupmappers(self): mapper(Architecture, self.tbl_architecture, @@ -2663,8 +2668,8 @@ class DBConn(object): primaryjoin=(self.tbl_changes.c.in_queue==self.tbl_policy_queue.c.id)), approved_for_id = self.tbl_changes.c.approved_for)) - mapper(ChangePendingBinary, self.tbl_changes_pending_binary, - properties = dict(change_pending_binary_id = self.tbl_changes_pending_binary.c.id)) + mapper(ChangePendingBinary, self.tbl_changes_pending_binaries, + properties = dict(change_pending_binary_id = self.tbl_changes_pending_binaries.c.id)) mapper(ChangePendingFile, self.tbl_changes_pending_files, properties = dict(change_pending_file_id = self.tbl_changes_pending_files.c.id))