Skip to content

Commit 4a2d1fc

Browse files
committed
Support for paginated results
1 parent add05a0 commit 4a2d1fc

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

QOpenScienceFramework/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.0.4"
1+
__version__ = "1.0.5"
22
__author__ = "Daniel Schreij"
33

44
import os

QOpenScienceFramework/widgets.py

+20
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,26 @@ def populate_tree(self, reply, parent=None):
15401540
if req:
15411541
self.active_requests.append(req)
15421542

1543+
# If the results are paginated, see if there is another page that needs
1544+
# to be processed
1545+
try:
1546+
next_page_url = osf_response['links']['next']
1547+
except AttributeError as e:
1548+
raise osf.OSFInvalidResponse("Invalid OSF data format for next page of "
1549+
"results. Missing attribute: {}".format(e))
1550+
1551+
if not next_page_url is None:
1552+
req = self.manager.get(
1553+
next_page_url,
1554+
self.populate_tree,
1555+
parent,
1556+
errorCallback=self.__populate_error
1557+
)
1558+
# If something went wrong, req should be None
1559+
if req:
1560+
self.active_requests.append(req)
1561+
1562+
# Remove current reply from list of active requests (assuming it finished)
15431563
try:
15441564
self.active_requests.remove(reply)
15451565
except ValueError:

0 commit comments

Comments
 (0)