Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6539985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:55:26+00:00 2026-05-25T10:55:26+00:00

Using webapp2 I create unit tests for a form where there are checkboxes for

  • 0

Using webapp2 I create unit tests for a form where there are checkboxes for votes so multiple values can be posted for the vote field and they are retrieved via request.POST.getall('vote'):

<input type="checkbox" name="vote" value="Better">
<input type="checkbox" name="vote" value="Faster">
<input type="checkbox" name="vote" value="Stronger">

In the unit test I tried passing a list:

response = app.get_response('/vote',
  POST={'vote': [u'Better', u'Faster', u'Stronger']},
  headers=[('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8')]
)

But looks like it’s simply converted to a string:

votes = self.request.POST.getall('vote')
# => [u"[u'Better', u'Faster', u'Stronger']"]

How can I pass multiple values for vote that will be retrieved as a list via request.POST.getall()?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:55:27+00:00Added an answer on May 25, 2026 at 10:55 am

    POST data is encoded using query string encoding, and multiple items by the same name are represented by repeating the key with different values. For instance:

    vote=Better&vote=Faster&vote=Stronger
    

    Python has library functions to do this for you, though:

    urllib.urlencode({
      'vote': ['Better', 'Faster', 'Stronger'],
    }, True)
    

    The second argument (True) to urlencode is called ‘doseq’, and instructs urlencode to encode sequences as lists of separate elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use Arquillian for some unit tests, however I can't find why
I'm developing software on google app engine. I'm using the webapp framework. is there
multiple webapp running on same tomcat using same jvm. sometime, one webapp that have
I've been asked to create a stand-alone webapp using straight HTML and Javascript that
I'm trying to create a multiaction web controller using Spring annotations. This controller will
I am developing a java webapp, using jsp/jquery/ejb/jboss. I have a web-form that enables
I'm using Eclipse 3.5, Maven 2, m2eclipse and Tomcat 6. So i create Maven
I have a webapp where users can create their account and use the service.
I´m using Reportlab to generate a PDF. Can´t retrieve a photo from a model.
i have a gwt project and using method GWT.create(SomeClass.class) throw exception. The exception is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.