logging.info('CREATED Collection for %s: %r' % ( DataSource.GUTENBERG, gutenberg)) _db.commit() # Alright, all the Collections have been created. Let's update the # LicensePools now. base_query = _db.query(LicensePool).filter(LicensePool.collection_id==None) single_collection_sources = [ DataSource.PLYMPTON, DataSource.ELIB, DataSource.UNGLUE_IT, DataSource.STANDARD_EBOOKS, DataSource.GUTENBERG ] for data_source_name in single_collection_sources: # Get the Collection. collection = Collection.by_datasource(_db, data_source_name).one() # Find LicensePools with the matching DataSource. source = DataSource.lookup(_db, data_source_name) qu = base_query.filter(LicensePool.data_source==source) qu.update({LicensePool.collection_id : collection.id}) logging.info('UPDATED: %d LicensePools given Collection %r' % ( int(fast_query_count(qu)), collection)) _db.commit() # Now update the FeedBooks LicensePools, which have to take language # into account. feedbooks = DataSource.lookup(_db, DataSource.FEEDBOOKS) base_query = _db.query(LicensePool.id)\ .filter(LicensePool.data_source==feedbooks)\