[英]My formencode.variabledecode is returning an empty list - Pylons
HTML:
<input type="text" name="blah-0" value="test" />
<input type="text" name="blah-1" value="another test" />
控制器:
class myvalidator(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
test = formencode.ForEach(formencode.validators.String())
def form_posted(self):
form_result = myvalidator().to_python(request.params)
print form_result
我想要得到的是返回的列表。 就像是:
> print form_result['blah']
['test', 'another test']
我究竟做錯了什么?
您的示例不完整,但是您必須在執行以下操作之前對變量進行解碼:
from formencode import variabledecode
def form_posted(self):
decoded = variabledecode.variable_decode(request.params)
form_result = myvalidator().to_python(decoded)
print form_result
如果需要,還應該更改該行:
test = formencode.ForEach(formencode.validators.String())
至:
blah = formencode.ForEach(formencode.validators.String())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.