Beispiel #1
0
        def methodNext(self, previous):
            """
      Takes a single argument, 'body', which is the results
      from the last call, and returns the next set of items
      in the collection.

      Returns None if there are no more items in
      the collection.
      """
            if futureDesc['type'] != 'uri':
                raise UnknownLinkType(futureDesc['type'])

            try:
                p = previous
                for key in futureDesc['location']:
                    p = p[key]
                url = p
            except (KeyError, TypeError):
                return None

            if self._developerKey:
                parsed = list(urlparse.urlparse(url))
                q = parse_qsl(parsed[4])
                q.append(('key', self._developerKey))
                parsed[4] = urllib.urlencode(q)
                url = urlparse.urlunparse(parsed)

            headers = {}
            headers, params, query, body = self._model.request(
                headers, {}, {}, None)

            logging.info('URL being requested: %s' % url)
            resp, content = self._http.request(url,
                                               method='GET',
                                               headers=headers)

            return self._requestBuilder(self._http,
                                        self._model.response,
                                        url,
                                        method='GET',
                                        headers=headers,
                                        methodId=methodId)
Beispiel #2
0
        def methodNext(self, previous):
            """Retrieve the next page of results.

      Takes a single argument, 'body', which is the results
      from the last call, and returns the next set of items
      in the collection.

      Returns:
        None if there are no more items in the collection.
      """
            if futureDesc['type'] != 'uri':
                raise UnknownLinkType(futureDesc['type'])

            try:
                p = previous
                for key in futureDesc['location']:
                    p = p[key]
                url = p
            except (KeyError, TypeError):
                return None

            url = _add_query_parameter(url, 'key', self._developerKey)

            headers = {}
            headers, params, query, body = self._model.request(
                headers, {}, {}, None)

            logging.info('URL being requested: %s' % url)
            resp, content = self._http.request(url,
                                               method='GET',
                                               headers=headers)

            return self._requestBuilder(self._http,
                                        self._model.response,
                                        url,
                                        method='GET',
                                        headers=headers,
                                        methodId=methodId)