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