- # max_id is inclusive so decrement by one
- # to avoid requesting duplicate items.
- max_id = self.since_id - 1 if self.max_id else None
- data = self.method(max_id = max_id, *self.args, **self.kargs)
- if len(data) == 0:
+ if self.index >= len(self.results) - 1:
+ data = self.method(max_id=self.max_id, parser=RawParser(), *self.args, **self.kargs)
+
+ if hasattr(self.method, '__self__'):
+ old_parser = self.method.__self__.parser
+ # Hack for models which expect ModelParser to be set
+ self.method.__self__.parser = ModelParser()
+
+ # This is a special invocation that returns the underlying
+ # APIMethod class
+ model = ModelParser().parse(self.method(create=True), data)
+ if hasattr(self.method, '__self__'):
+ self.method.__self__.parser = old_parser
+ result = self.method.__self__.parser.parse(self.method(create=True), data)
+ else:
+ result = model
+
+ if len(self.results) != 0:
+ self.index += 1
+ self.results.append(result)
+ self.model_results.append(model)
+ else:
+ self.index += 1
+ result = self.results[self.index]
+ model = self.model_results[self.index]
+
+ if len(result) == 0: