X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=9b757d13487887382595daa0cb23b55742301411;hb=904ac9b520fb3a9449a42f7f26e71c372789227d;hp=1bf44c858650951be219bfdeb1a5b8c360709dec;hpb=3fac3e435be2b886f6db5f2ef55d12ed3a32cac6;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 1bf44c85..9b757d13 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -508,19 +508,22 @@ class DBBinary(ORMObject): def scan_contents(self): ''' Yields the contents of the package. Only regular files are yielded and - the path names are normalized after converting them from either utf-8 or - iso8859-1 encoding. + the path names are normalized after converting them from either utf-8 + or iso8859-1 encoding. It yields the string ' ' if the + package does not contain any regular file. ''' fullpath = self.poolfile.fullpath dpkg = Popen(['dpkg-deb', '--fsys-tarfile', fullpath], stdout = PIPE) tar = TarFile.open(fileobj = dpkg.stdout, mode = 'r|') for member in tar.getmembers(): - if member.isfile(): + if not member.isdir(): + name = normpath(member.name) + # enforce proper utf-8 encoding try: - name = member.name.decode('utf-8') + name.decode('utf-8') except UnicodeDecodeError: - name = member.name.decode('iso8859-1') - yield normpath(name) + name = name.decode('iso8859-1').encode('utf-8') + yield name tar.close() dpkg.stdout.close() dpkg.wait() @@ -3288,7 +3291,7 @@ class DBConn(object): mapper(BinContents, self.tbl_bin_contents, properties = dict( binary = relation(DBBinary, - backref=backref('contents', lazy='dynamic')), + backref=backref('contents', lazy='dynamic', cascade='all')), file = self.tbl_bin_contents.c.file)) ## Connection functions @@ -3306,14 +3309,17 @@ class DBConn(object): connstr = "postgres:///%s" % cnf["DB::Name"] if cnf["DB::Port"] and cnf["DB::Port"] != "-1": connstr += "?port=%s" % cnf["DB::Port"] - if not cnf.has_key('DB::PoolSize'): - cnf['DB::PoolSize'] = '5' - if not cnf.has_key('DB::MaxOverflow'): - cnf['DB::MaxOverflow'] = '10' - - self.db_pg = create_engine(connstr, echo=self.debug, - pool_size=int(cnf['DB::PoolSize']), - max_overflow=int(cnf['DB::MaxOverflow'])) + + engine_args = { 'echo': self.debug } + if cnf.has_key('DB::PoolSize'): + engine_args['pool_size'] = int(cnf['DB::PoolSize']) + if cnf.has_key('DB::MaxOverflow'): + engine_args['max_overflow'] = int(cnf['DB::MaxOverflow']) + if sa_major_version == '0.6' and cnf.has_key('DB::Unicode') and \ + cnf['DB::Unicode'] == 'false': + engine_args['use_native_unicode'] = False + + self.db_pg = create_engine(connstr, **engine_args) self.db_meta = MetaData() self.db_meta.bind = self.db_pg self.db_smaker = sessionmaker(bind=self.db_pg,