Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Quetion about post fields #325

wsantos opened this Issue Aug 3, 2011 · 2 comments


None yet
2 participants

wsantos commented Aug 3, 2011

Why fields are in list in a post ?

(Pdb++) self.request.arguments
{'name': ['Cadaf'], 'email': ['Cadaf@cadaf.com']}

any reason for this ? thnx.


jehiah commented Aug 3, 2011

typically you don't access self.request.arguments directly but via self.get_argument() and self.get_arguments() docs

it's by design that it's a list so that the data type doesn't change between having one argument for that key, and multiple.


wsantos commented Aug 3, 2011

Thnx for the quick response, i got it. Btw i will register a simple way to use the post fields with wtform for future reference.

from wtforms import Form, TextField, validators

class TestForm(Form):
    field1     = TextField('field1', [validators.Length(min=4, max=25)])
    field2    = TextField('field2', [validators.Length(min=6, max=35)])

class HomeHandler(BaseHandler):

    def get(self):

    def post(self):
        form = TestForm(**dict([(key,self.get_argument(key)) for key in self.request.arguments]))
        validated = form.validate()

        self.write('Valid form: %r' % (validated))

@wsantos wsantos closed this Aug 3, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment