diff options
author | Cédric Bonhomme <kimble.mandel+bitbucket@gmail.com> | 2015-08-06 23:36:13 +0200 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel+bitbucket@gmail.com> | 2015-08-06 23:36:13 +0200 |
commit | 481d30d4b5d46608a7f0b5cf1122293bc61d3ea5 (patch) | |
tree | 4e8690425332988b84e62ebcd334f7bcb30bf89d /pyaggr3g470r/views/api | |
parent | Ensuere that the arguments is an integer. (diff) | |
parent | fixing bug preventing from bumping error count from api crawler for none admi... (diff) | |
download | newspipe-481d30d4b5d46608a7f0b5cf1122293bc61d3ea5.tar.gz newspipe-481d30d4b5d46608a7f0b5cf1122293bc61d3ea5.tar.bz2 newspipe-481d30d4b5d46608a7f0b5cf1122293bc61d3ea5.zip |
Merged in jaesivsm/pyaggr3g470r (pull request #21)
fixing bug on http crawler and light refact
Diffstat (limited to 'pyaggr3g470r/views/api')
-rw-r--r-- | pyaggr3g470r/views/api/article.py | 3 | ||||
-rw-r--r-- | pyaggr3g470r/views/api/common.py | 16 | ||||
-rw-r--r-- | pyaggr3g470r/views/api/feed.py | 3 |
3 files changed, 12 insertions, 10 deletions
diff --git a/pyaggr3g470r/views/api/article.py b/pyaggr3g470r/views/api/article.py index 03ecdb18..d2969cb0 100644 --- a/pyaggr3g470r/views/api/article.py +++ b/pyaggr3g470r/views/api/article.py @@ -51,7 +51,8 @@ class ArticlesChallenge(PyAggAbstractResource): if key in id_dict: id_dict[key] = dateutil.parser.parse(id_dict[key]) - return self.wider_controller.challenge(parsed_args['ids']) + result = list(self.wider_controller.challenge(parsed_args['ids'])) + return result or None, 200 if result else 204 g.api.add_resource(ArticleNewAPI, '/article', endpoint='article_new.json') diff --git a/pyaggr3g470r/views/api/common.py b/pyaggr3g470r/views/api/common.py index a7068807..acb5dd68 100644 --- a/pyaggr3g470r/views/api/common.py +++ b/pyaggr3g470r/views/api/common.py @@ -161,17 +161,17 @@ class PyAggResourceMulti(PyAggAbstractResource): """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' not in request.headers.get('Content-Type'): - raise BadRequest("Content-Type must be application/json") - limit = 10 try: limit = request.json.pop('limit', 10) + order_by = request.json.pop('order_by', None) + query = self.controller.read(**request.json) 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)] + limit, order_by, query = 10, None, self.controller.read() + if order_by: + query = query.order_by(order_by) + if limit: + query = query.limit(limit) + return [res for res in query] def post(self): """creating several objects. payload should be a list of dict. diff --git a/pyaggr3g470r/views/api/feed.py b/pyaggr3g470r/views/api/feed.py index 7d8cdf38..c80e9a9b 100644 --- a/pyaggr3g470r/views/api/feed.py +++ b/pyaggr3g470r/views/api/feed.py @@ -58,7 +58,8 @@ class FetchableFeedAPI(PyAggAbstractResource): contr = self.wider_controller else: contr = self.controller - return [feed for feed in contr.list_fetchable(**args)] + result = [feed for feed in contr.list_fetchable(**args)] + return result or None, 200 if result else 204 g.api.add_resource(FeedNewAPI, '/feed', endpoint='feed_new.json') |