10000 Update Pager to take and pass arguments to underlying callable (#451) · ecmyhre/server-client-python@d87600b · GitHub
[go: up one dir, main page]

Skip to content

Commit d87600b

Browse files
authored
Update Pager to take and pass arguments to underlying callable (tableau#451)
This enables us to use `get` methods that take optional parameters, like `usage` on get Views.
1 parent fa818d5 commit d87600b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tableauserverclient/server/pager.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from functools import partial
2+
13
from . import RequestOptions
24
from . import Sort
35

@@ -11,13 +13,15 @@ class Pager(object):
1113
Will loop over anything that returns (List[ModelItem], PaginationItem).
1214
"""
1315

14-
def __init__(self, endpoint, request_opts=None):
16+
def __init__(self, endpoint, request_opts=None, **kwargs):
1517

1618
if hasattr(endpoint, 'get'):
1719
# The simpliest case is to take an Endpoint and call its get
18-
self._endpoint = endpoint.get
20+
endpoint = partial(endpoint.get, **kwargs)
21+
self._endpoint = endpoint
1922
elif callable(endpoint):
2023
# but if they pass a callable then use that instead (used internally)
24+
endpoint = partial(endpoint, **kwargs)
2125
self._endpoint = endpoint
2226
else:
2327
# Didn't get something we can page over

0 commit comments

Comments
 (0)
0