aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2015-03-06 08:53:47 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2015-03-06 08:53:47 +0100
commitc8c3b06168127b5c61f74c0e37300ebbe05f0224 (patch)
treeb99bb4cbaaa67039baf3960264e3e1723653575c
parentCapure logging for InsecureRequestWarning (https). (diff)
downloadnewspipe-c8c3b06168127b5c61f74c0e37300ebbe05f0224.tar.gz
newspipe-c8c3b06168127b5c61f74c0e37300ebbe05f0224.tar.bz2
newspipe-c8c3b06168127b5c61f74c0e37300ebbe05f0224.zip
Feed GET HTTP resource accepts request with no json data (test).
-rw-r--r--pyaggr3g470r/views/api/common.py12
1 files changed, 8 insertions, 4 deletions
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/<id>
- -> to retreive one
+ -> to retrieve one
POST resource
-> to create one
PUT resource/<id>
@@ -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)]
bgstack15