Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. @Foo.method(http_method='POST',
  2. request_message=Foo.ProtoCollection(
  3. collection_fields=('foo', 'bar')),
  4. response_message=Foo.ProtoCollection(
  5. collection_fields=('id', 'foo', 'bar')),
  6. path='foo_multi')
  7. def insert_multi(self, foo_collection):
  8. entities = [Foo.FromMessage(item_msg).
  9. for item_msg in foo_collection.items]
  10. ndb.put_multi(entities)
  11. response_items = [entity.ToMessage() for entity in entities]
  12. return Foo.ProtoCollection()(items=response_items)
  13.  
  14. url = "http://localhost:8080/_ah/api/foobar/v1.0/foo_multi/"
  15. params = {"items": [
  16. {"foo": "random_words"},
  17. {"foo": "more_random_words"}
  18. ]}
  19. response = requests.post(url, params=params)
  20. print "users -> {0}".format(response.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement