

def pagination(cl):
    (paginator, page_num) = (cl.paginator, cl.page_num)
    pagination_required = (((not cl.show_all) or (not cl.can_show_all)) and cl.multi_page)
    if (not pagination_required):
        page_range = []
    else:
        ON_EACH_SIDE = 3
        ON_ENDS = 2
        if (paginator.pages <= 10):
            page_range = range(paginator.pages)
        else:
            page_range = []
            if (page_num > (ON_ENDS + ON_ENDS)):
                page_range.extend(range(0, (ON_EACH_SIDE - 1)))
                page_range.append(DOT)
                page_range.extend(range((page_num - ON_EACH_SIDE), (page_num + 1)))
            else:
                page_range.extend(range(0, (page_num + 1)))
            if (page_num < (((paginator.pages - ON_EACH_SIDE) - ON_ENDS) - 1)):
                page_range.extend(range((page_num + 1), ((page_num + ON_EACH_SIDE) + 1)))
                page_range.append(DOT)
                page_range.extend(range((paginator.pages - ON_ENDS), paginator.pages))
            else:
                page_range.extend(range((page_num + 1), paginator.pages))
    need_show_all_link = (cl.can_show_all and (not cl.show_all) and cl.multi_page)
    return {
        'cl': cl,
        'pagination_required': pagination_required,
        'show_all_url': (need_show_all_link and cl.get_query_string({
            ALL_VAR: '',
        })),
        'page_range': page_range,
        'ALL_VAR': ALL_VAR,
        '1': 1,
    }

dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-0.96/django/contrib/admin/templatetags/admin_list.py pagination/VarMisuse@111/147 `ON_EACH_SIDE`->`ON_ENDS`