]> git.decadent.org.uk Git - dak.git/commitdiff
Merge branch 'master' of ssh://ftp-master.debian.org/srv/ftp.debian.org/git/dak
authorTorsten Werner <twerner@debian.org>
Mon, 7 Feb 2011 22:15:21 +0000 (23:15 +0100)
committerTorsten Werner <twerner@debian.org>
Mon, 7 Feb 2011 22:15:21 +0000 (23:15 +0100)
1  2 
daklib/dbconn.py

diff --combined daklib/dbconn.py
index f0049a1a0c1addb7422bef47841cfff45218c9f9,dc5518a9a698363b5e7411bd1fd1bc4e001f554e..67852949fe35083dededb021e20418292315fa57
@@@ -53,7 -53,8 +53,8 @@@ from tempfile import mkstemp, mkdtem
  from inspect import getargspec
  
  import sqlalchemy
- from sqlalchemy import create_engine, Table, MetaData, Column, Integer, desc
+ from sqlalchemy import create_engine, Table, MetaData, Column, Integer, desc, \
+     Text, ForeignKey
  from sqlalchemy.orm import sessionmaker, mapper, relation, object_session, \
      backref, MapperExtension, EXT_CONTINUE, object_mapper
  from sqlalchemy import types as sqltypes
@@@ -465,12 -466,9 +466,9 @@@ __all__.append('get_archive'
  
  ################################################################################
  
- class BinContents(object):
-     def __init__(self, *args, **kwargs):
-         pass
-     def __repr__(self):
-         return '<BinContents (%s, %s)>' % (self.binary, self.filename)
+ class BinContents(ORMObject):
+     def properties(silf):
+         return ['file', 'binary']
  
  __all__.append('BinContents')
  
@@@ -491,7 -489,7 +489,7 @@@ class DBBinary(ORMObject)
      def properties(self):
          return ['package', 'version', 'maintainer', 'source', 'architecture', \
              'poolfile', 'binarytype', 'fingerprint', 'install_date', \
-             'suites_count', 'binary_id']
+             'suites_count', 'binary_id', 'contents_count']
  
      def not_null_constraints(self):
          return ['package', 'version', 'maintainer', 'source',  'poolfile', \
@@@ -2904,12 -2902,11 +2902,11 @@@ class DBConn(object)
              # 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',
 +            'changes',
 +            'build_queue_files',
          )
  
          tables_no_primary = (
-             'bin_contents',
              'changes_pending_files_map',
              'changes_pending_source_files',
              'changes_pool_files',
              'suite_build_queue_copy',
              'udeb_contents',
              # see the comment above
 -            'changes',
 -            'build_queue_files',
 +            #'changes',
 +            #'build_queue_files',
          )
  
          views = (
              table = Table(table_name, self.db_meta, autoload=True)
              setattr(self, 'tbl_%s' % table_name, table)
  
+         # bin_contents needs special attention until update #41 has been
+         # applied
+         self.tbl_bin_contents = Table('bin_contents', self.db_meta, \
+             Column('file', Text, primary_key = True),
+             Column('binary_id', Integer, ForeignKey('binaries.id'), \
+                 primary_key = True),
+             autoload=True, useexisting=True)
          for view_name in views:
              view = Table(view_name, self.db_meta, autoload=True)
              setattr(self, 'view_%s' % view_name, view)
                                   fingerprint = relation(Fingerprint, backref="uploadblocks"),
                                   uid = relation(Uid, backref="uploadblocks")))
  
+         mapper(BinContents, self.tbl_bin_contents,
+             properties = dict(
+                 binary = relation(DBBinary,
+                     backref=backref('contents', lazy='dynamic')),
+                 file = self.tbl_bin_contents.c.file))
      ## Connection functions
      def __createconn(self):
          from config import Config