0

I'm using web2py to create a page where I search for books based on title/author/keyword/etc. and ISBN, and I can't seem to figure out how to use isbntools in the webapp. I'm sure it's something basic that I'm missing out on, but this is the first webapp that I've ever created, and it's for a class project. This is the related portion of my controller:

from isbntools import *

def index():
    form=SQLFORM.factory(
     Field('title',label='Try entering a title:'),
     Field('author',label='Or an author:'),
     Field('ISBN',label='Even better if you have the ISBN'),
     Field('fromDate',label='When is the earliest the book might have come out?'),
     Field('toDate',label='...and the latest?'))
    if form.process().accepted:
        titledata = isbn_goom form.vars.title bibtex
        authordata = isbn_goom form.vars.author bibtex
        isbndata = isbn_meta merge form.vars.ISBN bibtex
        print(titledata)
        print(authordata)
        print(isbndata)
    return dict(form=form)

This is a portion of the ticket information I'm getting back:

Error ticket for "Bibbly" Ticket ID

96.255.27.81.2014-05-01.21-50-27.f66e0b53-b5bd-4621-8dbd-b6f30e8a6af1 invalid syntax (default.py, line 21) Version web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 Python Python 2.7.5+: /usr/local/bin/uwsgi (prefix: /usr) Traceback

line 21 titledata = isbn_goom "form.vars.title" bibtex ^ SyntaxError: invalid syntax

4

2 回答 2

0

isbm_goom是一个命令行脚本。那是你要的吗?!(你不能像那样在你的代码中使用它!)

我建议您使用最新版本isbntools并改编此片段

from isbntools.contrib.modules.goom import goom
from isbntools.dev.fmt import fmtbib

...

titledata = goom.query(form.vars.title)
for r in titledata:
    print((fmtbib('bibtex', r)))
于 2014-05-20T10:40:32.317 回答
0

由于 python 抱怨语法错误,这意味着它与您编写的文字代码有关。Python 解释器无法理解你的意思,因为你在语言中指定了一些“不可能”的东西。isbn_goom在这种情况下,它是关于和之后的空白form.vars.title。因为我不知道也没有看到任何关于isbn_goom我假设它来自isbntools图书馆的声明。要尝试该库,最好在您自己机器上的单独控制台会话中了解它。有关一些示例,请参见pypi 页面

关于解决语法错误:您可以尝试在任何体面的代码编辑器中编辑代码,它会为您提供有关此类错误的提示。任何默认安装附带的默认 python 编辑器 Idle 都会很棒。

于 2014-05-13T07:33:15.360 回答