문제

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

도움이 되었습니까?

해결책

isbm_goom is a command line script. Is that what you want?! (you cannot use it in your code like that!)

I suggests you use the most recent version of isbntools and adapt this snipet

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)))

다른 팁

Since python is complaining about a syntax error, it means it's about the literal code you've written. The Python interpreter can't grasp what you mean because you've specified something "impossible" in the language. In this case it's about the white-space after isbn_goom and form.vars.title. Since i don't know and don't see any declaration concerning isbn_goom i assume it's from the isbntools library. To try the library it may be best to learn about it in a separate console session on your own machine. See the pypi page for some examples.

On resolving syntax errors: You can try editing the code in any decent code editor and it will give you hints on these kinds of errors. The default python editor Idle that comes with any default installation would be great.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top