简体   繁体   English

运行web2py“图片博客”示例时出错

[英]get error when running web2py “image blog” example

I'm learning web2py, and have made it to the image blog example. 我正在学习web2py,并已进入图像博客示例。 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 可以在以下位置找到示例: 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. cast参数request.args()中的web2py 2.0中引入的。 The code should work if you upgrade to the latest version (currently 2.3.2). 如果您升级到最新版本(当前为2.3.2),则该代码应该有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM