get error when running web2py "image blog" example

I'm learning web2py, and have made it to the image blog example. However, I get an error when the controller tries interacting with the database?

More precisely, the line

image = db.image(request.args(0,cast=int)) or redirect(URL('index'))

causes an error (it's copy-pasted from the example). Looking at the error-logs, the first few lines are

(dp1
S'output'
p2
S"<type 'exceptions.TypeError'> __call__() got an unexpected keyword argument 'cast'"
p3
sS'layer'

The example can be found here: http://web2py.com/books/default/chapter/29/03

In an attempt at making a minimal working example, I've tried reducing the controller to just the offending line and an additional one passing a dict with a string. To comply with this, the view has been changed to just print the string. This still breaks, but works if I remove the database call. I have made sure that everything up to this point is always copied directly from the tutorial, so the database should be set up properly (indeed, the examples up to now using the database have worked as expected).

Any idea why this line is breaking?


The cast argument to request.args() was introduced in web2py 2.0. The code should work if you upgrade to the latest version (currently 2.3.2).

链接地址: http://www.djcxy.com/p/22752.html

上一篇: 如何将现有的MySQL数据库导入到web2py中?

下一篇: 运行web2py“图片博客”示例时出现错误