def _populate()

in libraries/edge/response/solrjsontemplateresponse.py [0:0]


    def _populate(self, solrResponse):
        start = 0
        rows = 0
        numFound = 0

        self.variables['parameters'] = self.parameters

        if solrResponse is not None:
            solrJson = json.loads(solrResponse, strict = False)

            self.variables['docs'] = solrJson['response']['docs']
            self.variables['numFound'] = int(solrJson['response']['numFound'])
            self.variables['itemsPerPage'] = int(solrJson['responseHeader']['params']['rows'])
            self.variables['startIndex'] = int(solrJson['response']['start'])

            if 'stats' in solrJson:
                self.variables['stats'] = solrJson['stats']

            if 'facet_counts' in solrJson:
                self.variables['facets'] = solrJson['facet_counts']

            start = int(solrJson['response']['start'])
            rows = int(solrJson['responseHeader']['params']['rows'])
            numFound = int(solrJson['response']['numFound'])


        self.parameters['startIndex'] = start
        self.variables['myself'] = self.link + '?' + urllib.parse.urlencode(self.parameters, True)

        if rows != 0:
            self.parameters['startIndex'] = numFound - (numFound % rows)
        self.variables['last'] = self.link + '?' + urllib.parse.urlencode(self.parameters, True)

        self.parameters['startIndex'] = 0
        self.variables['first'] = self.link + '?' + urllib.parse.urlencode(self.parameters, True)
        if start > 0:
            if (start - rows > 0):
                self.parameters['startIndex'] = start - rows
            self.variables['prev'] = self.link + '?' + urllib.parse.urlencode(self.parameters, True)

        if start + rows < numFound:
            self.parameters['startIndex'] = start + rows
            self.variables['next'] = self.link + '?' + urllib.parse.urlencode(self.parameters, True)