def query(self, id, limit=''):
        id = id.strip()
        if not sha1_re.search(id):
            error_now = ('You should be querying for a SHA1.  These are written in '
                         'hexadecimal (so they consist of a-f and 0-9).  Your query, '
                         '%s, is hence not a possible prefix.' % id)
        else:
            error_now = None
        id = id.lower()
        try:
            page = max(int(request.params.get('page', 0)), 1)
        except ValueError:
            page = 1
        try:
            limit = min(int(limit or request.params.get('limit', '')), 100)
        except ValueError:
            limit = 10
        offset = (page - 1) * limit
        matching, count = models.GitObject.lookup_by_sha1(sha1=id,
                                                          partial=True,
                                                          limit=limit)
        if count > 1:
            matching.skip(offset)
        c.page = page
        c.start = offset + 1
        c.end = min(page * limit, count)
        c.limit = limit
        c.objects = matching
        c.count = count
        c.queried_id = id
        # Nonsensical if count == 0
        c.out_of_range = c.start > count
        return render('query.mako', controller='query', error_now=error_now)
dataset/ETHPy150Open ebroder/anygit/anygit/controllers/query.py/QueryController.query/original