def __init__(self, qs, request):
        self.qs = qs
        self.request = request

        self.page_size = request.session.get('page_size',
            self.available_page_sizes[0])

        # overwrite with new value, if it is correct
        if 'page_size' in request.GET:
            try:
                ps = int(request.GET['page_size'])
                if ps in self.available_page_sizes:
                    self.page_size = ps
                    request.session['page_size'] = ps
            except exceptions.ValueError:
                pass

        try:
            self.page_number = int(request.GET.get('page', '1'))
        except __HOLE__:
            self.page_number = 1

        self.paginator = Paginator(self.qs, self.page_size)

        try:
            self.page = self.paginator.page(self.page_number)
        except (EmptyPage, InvalidPage):
            self.page = self.paginator.page(self.paginator.num_pages)

        # calculate pages
        self.pages = []

        add_none = True
        for page in self.paginator.page_range:
            if (page < 3
                or self.paginator.num_pages - page < 3
                or abs(page - self.page.number) < 3):
                add_none = True
                self.pages.append(page)
            elif add_none:
                self.pages.append(None)
                add_none = False

        # create get_vars
        get_vars = request.GET.copy()
        if 'page' in get_vars:
            del get_vars['page']
        if len(get_vars.keys()) > 0:
            self.get_vars = "&%s" % get_vars.urlencode()
        else:
            self.get_vars = ''
        if 'page_size' in get_vars:
            del get_vars['page_size']
        self.hidden_inputs = get_vars.items()
dataset/ETHPy150Open dndtools/dndtools/dndtools/dnd/dnd_paginator.py/DndPaginator.__init__