def collection(self): """Returns an associated Collection object :return: Associated Collection object :rtype: Collection """ return Collection.by_id(self._db, id=self._collection_id)
def look_up_collection_by_id(self, identifier): """Find the collection to display self test results or run self tests for; display an error message if a collection with this ID turns out not to exist""" collection = Collection.by_id(self._db, identifier) if not collection: return NO_SUCH_COLLECTION return collection
def collection(self): return Collection.by_id(self._db, id=self.collection_id)
def collection(self, _db): """Find the Collection to which this object belongs.""" return Collection.by_id(_db, self.collection_id)
rb_collection_id = rb_digital_collections[0][0] source = DataSource.lookup(_db, DataSource.RB_DIGITAL) update_statement = update(Credential)\ .where(and_( Credential.data_source_id == source.id, Credential.type == Credential.IDENTIFIER_FROM_REMOTE_SERVICE ))\ .values(collection_id=rb_collection_id) _db.execute(update_statement) # We have multiple RBDigital integration and we don't know which credential # belongs to each one. Have to check each credential against RBDigital API. else: rb_api = [] for collection_id in rb_digital_collections: collection = Collection.by_id(_db, collection_id[0]) rb_api.append(RBDigitalAPI(_db, collection)) source = DataSource.lookup(_db, DataSource.RB_DIGITAL) credentials = _db.query(Credential)\ .filter( Credential.data_source_id == source.id, Credential.type == Credential.IDENTIFIER_FROM_REMOTE_SERVICE, Credential.credential != None ) for credential in credentials: for api in rb_api: if check_patron_id(api, credential.credential): credential.collection = api.collection break # Remove credentials stored with none as the credential