<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def search(self, query, pagination, result_field):
 """ Perform Pagure query """

        result = []
        url = "/".join((self.url, query))
        while url:
            log.debug("Pagure query: {0}".format(url))
            try:
                response = requests.get(url, headers=self.headers)
                log.data("Response headers:\n{0}".format(response.headers))
            except requests.RequestException as error:
                log.error(error)
                raise ReportError("Pagure search {0} failed.".format(self.url))
            data = response.json()
            objects = data[result_field]
            log.debug("Result: {0} fetched".format(
                listed(len(objects), "item")))
            log.data(pretty(data))
            # FIXME later: Work around https://pagure.io/pagure/issue/4057
            if not objects:
                break
            result.extend(objects)
            url = data[pagination]['next']
        return result