我正在使用 web.py 作为框架构建一个网站。
这就是我的网址:
urls = (
'/', 'index',
'/search', 'search',
'/book/(.*)', 'book'
)
这是 book 类的样子:
class book:
def GET(self, isbn):
isbnvar = "isbn = '{0}'".format(isbn)
book_details = db.select('books_bookdata',where=isbnvar)
return render.book(book_details,price) # price is a global variable
编辑:我的书模板以 -
$def with (book_details, price)
转到 /book/9876543210987 会引发__template__() takes no arguments (2 given)
错误。我无法弄清楚我做错了什么。
编辑:这是完整的追溯
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 239, in process
return self.handle()
File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 230, in handle
return self._delegate(fn, self.fvars, args)
File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 420, in _delegate
return handle_class(cls)
File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 396, in handle_class
return tocall(*args)
File "/home/chaitanya/justcompare/code.py", line 45, in GET
return render.book(book_details,price)
File "/usr/local/lib/python2.7/dist-packages/web/template.py", line 881, in __call__
return BaseTemplate.__call__(self, *a, **kw)
File "/usr/local/lib/python2.7/dist-packages/web/template.py", line 808, in __call__
return self.t(*a, **kw)
TypeError: __template__() takes no arguments (2 given)