0

When I reference the params parameter of the WebOb Request an element is suddenly popped off the end. That or it's being reduced to a single element. The referenced element isn't the one getting knocked off.

if req.str_params.has_key('method'):
   req.method = req.str_params.getone('method')

Before this line logging turns up:

DEBUG:root:NestedMultiDict([('method', 'put'), ('name', 'some_name')])

after:

DEBUG:root:NestedMultiDict([('method', 'put')])

I'm at a loss.

4

1 回答 1

2

这是因为您正在设置req.method. 可能name=some_name在请求的正文中,只要req.method == 'POST'您能取回该参数。当您将方法更改为 PUT 时,您将阻止 WebOb 解析请求正文(请求正文应该是实体,而不是 HTML 表单输入)。这是在您获取属性时计算的req.str_params,因此通过保存对参数的引用,您可以避免 req.method 检查。

于 2011-08-03T21:54:53.323 回答