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

  • SEARCH
  • Home
  • 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 3300904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:42:10+00:00 2026-05-17T20:42:10+00:00

I’m trying to simulate some data in to the datastore to emulate POSTs. What

  • 0

I’m trying to simulate some data in to the datastore to emulate POSTs.

What I’m looking for is a way to post named arguments but as one argument. So I can use the same method as a normal POST would do.

The method I want to invoke get params in two ways.

def HandlePost(params):
    params.get('name')
    params.get_all('collection')

class SavePartHandler(webapp.RequestHandler):
    def post(self):
        HandlePost(self.request)

I’m trying to find out what type the self.request are but can’t find it anywhere in appengines source code.

My goal is to simulate multiple POST to fill the datastore by the methods users would.

EDIT:

Or is the anyway to change the behavior of dict so it could use the get_all method?

EDIT 2:

I’m using appengins webapp.

Out of curiosity is there a way to invoke a dummy webapp.RequestHandler and populate it with arguments? I’m browsing the source code to see how it’s done and made a new instance of it but can’t find how to populate it.

EDIT 3:

Updated method name so it’s not confused with webapp request handlers.

Thanks to pthulin I’m almost there. Only thing left is how to simulate data that has the same key. Since using a dict will override other keys with the same name. Sometimes in HTML forms a post can contain multiple values for the same key that we get with self.request.get_all('key'). So how to create a dict (or something equal) that supports multiple key=value with same key.

..fredrik

  • 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-17T20:42:10+00:00Added an answer on May 17, 2026 at 8:42 pm

    I think what you want to do is prepare a webapp Request object and then call the post method of your handler:

    from google.appengine.ext.webapp import Request
    from google.appengine.ext.webapp import Response
    from StringIO import StringIO
    form = 'msg=hello'
    handler.response = Response()
    handler.request = Request({
        'REQUEST_METHOD': 'POST',
        'PATH_INFO': '/',
        'wsgi.input': StringIO(form),
        'CONTENT_LENGTH': len(form),
        'SERVER_NAME': 'hi',
        'SERVER_PORT': '80',
        'wsgi.url_scheme': 'http',
    })
    handler.post()
    

    TIP: ‘msg=hello’ above works fine in this case, but to pass multiple POST parameters you need to create a URL encoded string:

    >>> form = {
    ...     'first_name': 'Per',
    ...     'last_name': 'Thulin',
    ... }
    >>> from urllib import urlencode
    >>> urlencode(form)
    'first_name=Per&last_name=Thulin'
    

    If you want to pass in multiple POST parameters with the same name, I think you need to do a little bit of the url encoding work yourself. For example:

    >>> from urllib import urlencode
    >>> form_inputs = [
    ...     {'someparam': 'aaa'},
    ...     {'someparam': 'bbb'},
    ...     {'someparam': 'ccc'},
    ... ]
    >>> '&'.join([urlencode(d) for d in form_inputs])
    'someparam=aaa&someparam=bbb&someparam=ccc'
    

    Then in the RequestHandler, you can extract the parameters with the Request.get_all method.

    • http://code.google.com/appengine/docs/python/tools/webapp/requestclass.html
    • http://code.google.com/appengine/docs/python/tools/webapp/requestclass.html#Request_get_all
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to construct a data frame in an Rcpp function, but when I
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.