当前位置: 首页>>代码示例>>Python>>正文


Python Book.delete方法代码示例

本文整理汇总了Python中models.Book.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Book.delete方法的具体用法?Python Book.delete怎么用?Python Book.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Book的用法示例。


在下文中一共展示了Book.delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_book_deletion

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import delete [as 别名]
 def test_book_deletion(self):
     self.assertEquals(0, Book.all().count())
     book = Book(
        title = "test",
        ident = "1",
        author = "author",
        notes = "",
        image = "http://example.com/image.gif",
        url = "http://example.com"
     )    
     book.put()  
     self.assertEquals(1, Book.all().count())
     book.delete()
     self.assertEquals(0, Book.all().count())
开发者ID:garethr,项目名称:appengine-books,代码行数:16,代码来源:book.py

示例2: delete_book

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import delete [as 别名]
def delete_book(book_id):
    Book.delete(book_id)
    return redirect(url_for('books'))
开发者ID:yaroslav-dudar,项目名称:prom-ua-test-task,代码行数:5,代码来源:views.py

示例3: m_book_delete

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import delete [as 别名]
def m_book_delete():
    bid = request.form.get('bid')
    Book.delete(bid)
    return redirect(request.referrer)
开发者ID:amumu,项目名称:wyzq,代码行数:6,代码来源:app.py

示例4: delete

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import delete [as 别名]
def delete(request):
    if "isbn" in request.GET:
        Isbn = request.GET["isbn"]
        book1 = Book.objects.get(ISBN=Isbn)
        Book.delete(book1)
    return render_to_response("delete.html")
开发者ID:zzzsgit,项目名称:lab4_2,代码行数:8,代码来源:views.py

示例5: scan

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import delete [as 别名]
    def scan(self): 
        try:
            if sys.platform == 'win32':
                ZBARPATH = list(which('zbarcam'))
                if not ZBARPATH:
                    ZBARPATH = list(which('zbarcam', path=[r"C:\Program Files\ZBar\bin", r"C:\Program Files (x86)\ZBar\bin"]))[0]
            else:
                ZBARPATH = list(which('zbarcam'))[0]
        except:
            ZBARPATH = None
        if not ZBARPATH:
            QtGui.QMessageBox.information(None, "Aranduka - Error", "Can't find zbarcam. Get it at http://zbarcam.sf.net")
            return
        p=os.popen(ZBARPATH,'r')
        p = subprocess.Popen([ZBARPATH], stdout=subprocess.PIPE).communicate()[0]
        # p = "DEMO:0345400445"
        guesser = manager.getPluginsOfCategory('Guesser')[0]
        for code in p.splitlines():
            print("scanning")
            if code:
                print(('Got barcode:', code))
                isbn = code.split(':')[1]
                # QtGui.QDesktopServices.openUrl(QtCore.QUrl('http://www.goodreads.com/search/search?q=%s'%isbn))
                i = Identifier(key='ISBN', value=isbn)
                # Create empty book
                b = Book(identifiers = [i])
                # We are supposed to have a ISBN, so assume we are getting it right.
                dlg = GuessDialog(b)
                dlg.isbn.setChecked(True)
                dlg.on_guessButton_clicked()

                r = dlg.exec_()
                
                # FIXME this is copied from book_editor. 
                # The Book class probably needs an "update from metadata" method.
                md = None
                if not r == dlg.Accepted:
                    md = None
                    b.delete()
                elif dlg.currentMD:
                    md =  dlg.currentMD

                    if md is None:
                        return
                    else:
                        # A candidate was chosen, update data
                        print(md)
                        b.title = md.title
                        if md.identifiers is not None:
                            for k,v in md.identifiers:
                                i = Identifier(
                                        key=k.upper(), 
                                        value=v,
                                        book=b)
                        b.authors = []
                        for a in md.authors:
                            author = Author.get_by(name = a)
                            if not author:
                                print(("Creating author:", a))
                                author = Author(name = a)
                            b.authors.append(author)
                        Author.sanitize()
                        # FIXME: it seems Qt can't parse alibris cover images?
                        # b.fetch_cover(md.thumbnail)
                        b.fetch_cover()
                    session.commit()
开发者ID:webmedic,项目名称:booker,代码行数:68,代码来源:__init__.py


注:本文中的models.Book.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。