Skip to content

Instantly share code, notes, and snippets.

@topless
Last active July 4, 2016 11:28
Show Gist options
  • Save topless/b7a4e3d8d9b4b9aa7de67915022b61ee to your computer and use it in GitHub Desktop.
Save topless/b7a4e3d8d9b4b9aa7de67915022b61ee to your computer and use it in GitHub Desktop.
gae-init rest api arguments as query params.
# Parsing request arguments and passing them to our db query with validation ;)
@api_v1.resource('/foo/', endpoint='api.foo.list')
class FooListAPI(restful.Resource):
def get(self):
args = parser.parse({
'name': wf.Str(missing=None),
'limit': wf.Int(missing=config.DEFAULT_DB_LIMIT),
'order': wf.Str(missing='-created')
})
foo_dbs, cursor = model.Foo.get_dbs(**args)
return helpers.make_response(foo_dbs, model.Foo.FIELDS, cursor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment