Пример #1
0
 def get(self):
     db = getUtility(IRelationalDatabase)
     cr = db.cursor()
     barcode = self.book.barcode
     if barcode:
         cr.execute("""SELECT
                         id,
                         barcode,
                         author,
                         title
                       FROM books
                       WHERE barcode = ?""",
                    (barcode,))
     else:
         cr.execute("""SELECT
                         id,
                         barcode,
                         author,
                         title
                       FROM books""")
     rst = cr.fetchall()
     cr.close()
     books = []
     for record in rst:
         id = record['id']
         barcode = record['barcode']
         author = record['author']
         title = record['title']
         book = Book()
         book.id = id
         book.barcode = barcode
         book.author = author
         book.title = title
         books.append(book)
     return books
Пример #2
0
 def on_add_clicked(self, *args):
     barcode = self.barcode.get_text()
     author = self.author.get_text()
     title = self.title.get_text()
     book = Book()
     book.barcode = barcode
     book.author = author
     book.title = title
     self.add(book)
     self.list_store.append((book, barcode, author, title))