parser = parse_search_results,
allowed_param = ['q', 'lang', 'locale', 'rpp', 'page', 'since_id', 'geocode', 'show_user'],
)(self, *args, **kargs)
+ search.pagination_mode = 'page'
""" trends
raise ImportError, "Can't load a json library"
-def bind_api(path, parser, allowed_param=None, method='GET', require_auth=False,
+def bind_api(path, parser, allowed_param=[], method='GET', require_auth=False,
timeout=None, host=None):
def _call(api, *args, **kargs):
return out
- # Expose extra data in callable object
- _call.allowed_param = allowed_param
+
+ # Set pagination mode
+ if 'cursor' in allowed_param:
+ _call.pagination_mode = 'cursor'
+ elif 'page' in allowed_param:
+ _call.pagination_mode = 'page'
return _call
"""Pagination helper class"""
def __init__(self, method, *args, **kargs):
- if 'cursor' in method.allowed_param:
- self.iterator = CursorIterator(method, args, kargs)
- elif 'page' in method.allowed_param:
- self.iterator = PageIterator(method, args, kargs)
+ if hasattr(method, 'pagination_mode'):
+ if method.pagination_mode == 'cursor':
+ self.iterator = CursorIterator(method, args, kargs)
+ else:
+ self.iterator = PageIterator(method, args, kargs)
else:
raise TweepError('This method does not perform pagination')