o
    ˷e	                     @   s"   d dl mZmZ G dd dZdS )    )	EmptyPagePageNotAnIntegerc                   @   s"   e Zd ZdZdddZdd ZdS )	RequestConfiga  
    A configurator that uses request data to setup a table.

    A single RequestConfig can be used for multiple tables in one view.

    Arguments:
        paginate (dict or bool): Indicates whether to paginate, and if so, what
            default values to use. If the value evaluates to `False`, pagination
            will be disabled. A `dict` can be used to specify default values for
            the call to `~.tables.Table.paginate` (e.g. to define a default
            `per_page` value).

            A special *silent* item can be used to enable automatic handling of
            pagination exceptions using the following logic:

             - If `~django.core.paginator.PageNotAnInteger` is raised, show the first page.
             - If `~django.core.paginator.EmptyPage` is raised, show the last page.

            For example, to use `~.LazyPaginator`::

                RequestConfig(paginate={"paginator_class": LazyPaginator}).configure(table)

    Tc                 C   s   || _ || _d S )N)requestpaginate)selfr   r    r   L/var/www/ideatree/venv/lib/python3.10/site-packages/django_tables2/config.py__init__   s   
zRequestConfig.__init__c              
   C   s  | j j|j}|r||_| jr~t| jdrt| j}ni }dD ] }t|d| }zt	| j j| ||< W q  t
tfy@   Y q w |dd}|sR|jdi | n,z
|jdi | W n! tyl   |jd|_Y n ty}   |j|jj|_Y nw | j |_ |S )	z
        Configure a table using information from the request.

        Arguments:
            table (`~.Table`): table to be configured
        items)pageper_pagezprefixed_%s_fieldsilentT   Nr   )r   GETgetlistprefixed_order_by_fieldorder_byr   hasattrdictgetattrint
ValueErrorKeyErrorpopr   	paginatorr   r   	num_pages)r   tabler   kwargsargnamer   r   r   r	   	configure!   s4   zRequestConfig.configureN)T)__name__
__module____qualname____doc__r
   r!   r   r   r   r	   r      s    
r   N)django.core.paginatorr   r   r   r   r   r   r	   <module>   s    