def get(self): db = getUtility(IRelationalDatabase) cr = db.cursor() id = self.circulation.id if id: cr.execute("""SELECT id, member_id, book_id FROM circulations WHERE id = ?""", (id,)) else: cr.execute("""SELECT id, member_id, book_id FROM circulations""") rst = cr.fetchall() cr.close() circulations = [] for record in rst: id = record['id'] member_id = record['member_id'] book_id = record['book_id'] circulation = Circulation() circulation.id = id circulation.member_id = member_id circulation.book_id = book_id circulations.append(circulation) return circulations
def get(self): db = getUtility(IRelationalDatabase) cr = db.cursor() id = self.circulation.id if id: cr.execute( """SELECT id, member_id, book_id FROM circulations WHERE id = ?""", (id, )) else: cr.execute("""SELECT id, member_id, book_id FROM circulations""") rst = cr.fetchall() cr.close() circulations = [] for record in rst: id = record['id'] member_id = record['member_id'] book_id = record['book_id'] circulation = Circulation() circulation.id = id circulation.member_id = member_id circulation.book_id = book_id circulations.append(circulation) return circulations
def book_return(self, book_barcode): book = Book() book.number = book_barcode bookdboperation = getAdapter(book, IDbOperation) book = bookdboperation.get()[0] circulation = Circulation() circulation.book = book circulationdboperation = getAdapter(circulation, IDbOperation) circulationdboperation.delete()
def book_issue(self, member_number, book_barcode): member = Member() member.number = member_number memberdboperation = getAdapter(member, IDbOperation) member = memberdboperation.get()[0] book = Book() book.number = book_barcode bookdboperation = getAdapter(book, IDbOperation) book = bookdboperation.get()[0] circulation = Circulation() circulation.member = member circulation.book = book circulationdboperation = getAdapter(circulation, IDbOperation) circulationdboperation.add()