Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Foo.method(http_method='POST',
- request_message=Foo.ProtoCollection(
- collection_fields=('foo', 'bar')),
- response_message=Foo.ProtoCollection(
- collection_fields=('id', 'foo', 'bar')),
- path='foo_multi')
- def insert_multi(self, foo_collection):
- entities = [Foo.FromMessage(item_msg).
- for item_msg in foo_collection.items]
- ndb.put_multi(entities)
- response_items = [entity.ToMessage() for entity in entities]
- return Foo.ProtoCollection()(items=response_items)
- url = "http://localhost:8080/_ah/api/foobar/v1.0/foo_multi/"
- params = {"items": [
- {"foo": "random_words"},
- {"foo": "more_random_words"}
- ]}
- response = requests.post(url, params=params)
- print "users -> {0}".format(response.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement