def query(self, id): if not sha1_re.search(id): error_now = ('You should be querying for a SHA1. These are written in ' 'hexidecimal (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() # Invalid params will throw an exception. page = max(int(request.params.get('page', 0)), 1) limit = min(int(request.params.get('limit', 10)), 50) offset = (page - 1) * limit matching, count = models.GitObject.lookup_by_sha1(sha1=id, partial=True, offset=offset, limit=limit) 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 if c.start > count: c.out_of_range = True else: c.out_of_range = False return render('query.mako', controller='query', error_now=error_now)
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)
def index(self): return render('index.mako', controller='query')
def about(self): return render('about.mako', controller='index')
def about(self): return render("about.mako", controller="index")
def index(self): return render("index.mako", controller="index")