From c8c3b06168127b5c61f74c0e37300ebbe05f0224 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Fri, 6 Mar 2015 08:53:47 +0100 Subject: Feed GET HTTP resource accepts request with no json data (test). --- pyaggr3g470r/views/api/common.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'pyaggr3g470r/views/api') diff --git a/pyaggr3g470r/views/api/common.py b/pyaggr3g470r/views/api/common.py index 48a0d0ac..bfdc7860 100644 --- a/pyaggr3g470r/views/api/common.py +++ b/pyaggr3g470r/views/api/common.py @@ -1,7 +1,7 @@ """For a given resources, classes in the module intend to create the following routes : GET resource/ - -> to retreive one + -> to retrieve one POST resource -> to create one PUT resource/ @@ -10,7 +10,7 @@ routes : -> to delete one GET resources - -> to retreive several + -> to retrieve several POST resources -> to create several PUT resources @@ -146,12 +146,16 @@ class PyAggResourceExisting(PyAggAbstractResource): class PyAggResourceMulti(PyAggAbstractResource): def get(self): - """retreive several objects. filters can be set in the payload on the + """retrieve several objects. filters can be set in the payload on the different fields of the object, and a limit can be set in there as well """ if 'application/json' != request.headers.get('Content-Type'): raise BadRequest("Content-Type must be application/json") - limit = request.json.pop('limit', 10) + limit = 10 + try: + limit = request.json.pop('limit', 10) + except: + return [res for res in self.controller.read().limit(limit)] if not limit: return [res for res in self.controller.read(**request.json).all()] return [res for res in self.controller.read(**request.json).limit(limit)] -- cgit