[Python-modules-commits] [python-digitalocean] 01/19: activates the pagination if more elements are there. #146

Andrew Starr-Bochicchio asb at moszumanska.debian.org
Tue Jun 20 00:31:27 UTC 2017


This is an automated email from the git hooks/post-receive script.

asb pushed a commit to annotated tag 1.10.1
in repository python-digitalocean.

commit d778a48926f21d34654a9fe27d1b389d0f42bf60
Author: Lorenzo Setale <lorenzo at setale.me>
Date:   Sun Aug 28 14:20:39 2016 +0200

    activates the pagination if more elements are there. #146
---
 digitalocean/Manager.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/digitalocean/Manager.py b/digitalocean/Manager.py
index 49ae662..1598b23 100644
--- a/digitalocean/Manager.py
+++ b/digitalocean/Manager.py
@@ -37,8 +37,14 @@ class Manager(BaseAPI):
 
         kwargs["params"] = params
         data = super(Manager, self).get_data(*args, **kwargs)
-        if kwargs.get('type') == GET:
-            return self.__deal_with_pagination(args[0], data, params)
+        # if there are more elements available (total) than the elements per 
+        # page, try to deal with pagination. Note: Breaking the logic on
+        # multiple pages,
+        if 'meta' in data:
+            if 'total' in data['meta']['total'] > params['per_page']:
+                return self.__deal_with_pagination(args[0], data, params)
+            else:
+                return data
         else:
             return data
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-digitalocean.git



More information about the Python-modules-commits mailing list