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" />
Controller:
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 fo开发者_StackOverflowrm_result
What I'm trying to get is a list returned. Something like:
> print form_result['blah']
['test', 'another test']
What am I doing wrong?
Your example is incomplete but you must decode your variables before:
from formencode import variabledecode
def form_posted(self):
decoded = variabledecode.variable_decode(request.params)
form_result = myvalidator().to_python(decoded)
print form_result
You also should change that line if you want blah:
test = formencode.ForEach(formencode.validators.String())
to:
blah = formencode.ForEach(formencode.validators.String())
精彩评论