a
    ތxd                     @   s6   d dl mZ d dlmZ d dlmZ G dd dZdS )    )render_to_string)settings)get_name_from_objc                   @   s   e Zd ZdZdd Zedd Zedd Zedd	 Zed
d Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zed,d- Zd.S )/Panelz 
    Base class for panels.
    c                 C   s   || _ || _d S N)toolbarget_response)selfr   r    r
   U/var/www/html/Ranjet/env/lib/python3.9/site-packages/debug_toolbar/panels/__init__.py__init__   s    zPanel.__init__c                 C   s   | j jS r   )	__class____name__r	   r
   r
   r   panel_id   s    zPanel.panel_idc                 C   sV   t  d }t| }||v p*|dd|v }|r6d}nd}| jjjd| j |dkS )NZDISABLE_PANELSz.panel..offonZdjdt)	dt_settingsZ
get_configr   replacer   requestZCOOKIESgetr   )r	   Zdisabled_panelsZ
panel_pathZdisable_paneldefaultr
   r
   r   enabled   s    zPanel.enabledc                 C   s   | j S )zI
        Title shown in the side bar. Defaults to :attr:`title`.
        )titler   r
   r
   r   	nav_title,   s    zPanel.nav_titlec                 C   s   dS )zO
        Subtitle shown in the side bar. Defaults to the empty string.
         r
   r   r
   r
   r   nav_subtitle3   s    zPanel.nav_subtitlec                 C   s   dS )z
        ``True`` if the panel can be displayed in full screen, ``False`` if
        it's only shown in the side bar. Defaults to ``True``.
        Tr
   r   r
   r
   r   has_content:   s    zPanel.has_contentc                 C   s   | j S )zg
        Panel supports rendering historical values.

        Defaults to :attr:`has_content`.
        )r   r   r
   r
   r   is_historicalB   s    zPanel.is_historicalc                 C   s   t dS )z
        Title shown in the panel when it's displayed in full screen.

        Mandatory, unless the panel sets :attr:`has_content` to ``False``.
        NNotImplementedErrorr   r
   r
   r   r   K   s    zPanel.titlec                 C   s   t dS )z
        Template used to render :attr:`content`.

        Mandatory, unless the panel sets :attr:`has_content` to ``False`` or
        overrides `attr`:content`.
        Nr    r   r
   r
   r   templateT   s    zPanel.templatec                 C   s   | j rt| j|  S dS )z
        Content of the panel when it's displayed in full screen.

        By default this renders the template defined by :attr:`template`.
        Statistics stored with :meth:`record_stats` are available in the
        template's context.
        N)r   r   r"   	get_statsr   r
   r
   r   content^   s    	zPanel.contentc                 C   s   g S )zT
        Scripts used by the HTML content of the panel when it's displayed.
        r
   r   r
   r
   r   scriptsj   s    zPanel.scriptsc                 C   s   g S )zE
        Return URLpatterns, if the panel has its own views.
        r
   clsr
   r
   r   get_urlss   s    zPanel.get_urlsc                 C   s   dS )a  
        Enable instrumentation to gather data for this panel.

        This usually means monkey-patching (!) or registering signal
        receivers. Any instrumentation with a non-negligible effect on
        performance should be installed by this method rather than at import
        time.

        Unless the toolbar or this panel is disabled, this method will be
        called early in ``DebugToolbarMiddleware``. It should be idempotent.
        Nr
   r   r
   r
   r   enable_instrumentation|   s    zPanel.enable_instrumentationc                 C   s   dS )a  
        Disable instrumentation to gather data for this panel.

        This is the opposite of :meth:`enable_instrumentation`.

        Unless the toolbar or this panel is disabled, this method will be
        called late in the middleware. It should be idempotent.
        Nr
   r   r
   r
   r   disable_instrumentation   s    zPanel.disable_instrumentationc                 C   s   | j j| ji | dS )
        Store data gathered by the panel. ``stats`` is a :class:`dict`.

        Each call to ``record_stats`` updates the statistics dictionary.
        N)r   stats
setdefaultr   update)r	   r,   r
   r
   r   record_stats   s    zPanel.record_statsc                 C   s   | j j| ji S zK
        Access data stored by the panel. Returns a :class:`dict`.
        )r   r,   r   r   r   r
   r
   r   r#      s    zPanel.get_statsc                 C   s*   |||di}| j j| ji | dS )r+   )r   valueN)r   server_timing_statsr-   r   r.   )r	   keyr   r1   datar
   r
   r   record_server_timing   s    zPanel.record_server_timingc                 C   s   | j j| ji S r0   )r   r2   r   r   r   r
   r
   r   get_server_timing_stats   s    zPanel.get_server_timing_statsc                 C   s
   |  |S )z
        Like __call__ in Django's middleware.

        Write panel logic related to the request there. Save data with
        :meth:`record_stats`.

        Return the existing response or overwrite it.
        )r   )r	   r   r
   r
   r   process_request   s    	zPanel.process_requestc                 C   s   dS )a  
        Called after :meth:`process_request
        <debug_toolbar.panels.Panel.process_request>`, but may not be executed
        on every request. This will only be called if the toolbar will be
        inserted into the request.

        Write panel logic related to the response there. Post-process data
        gathered while the view executed. Save data with :meth:`record_stats`.

        Does not return a value.
        Nr
   r	   r   responser
   r
   r   generate_stats   s    zPanel.generate_statsc                 C   s   dS )z
        Similar to :meth:`generate_stats
        <debug_toolbar.panels.Panel.generate_stats>`,

        Generate stats for Server Timing https://w3c.github.io/server-timing/

        Does not return a value.
        Nr
   r8   r
   r
   r   generate_server_timing   s    zPanel.generate_server_timingc                 C   s   g S )a  
        Check that the integration is configured correctly for the panel.

        This will be called as a part of the Django checks system when the
        application is being setup.

        Return a list of :class: `django.core.checks.CheckMessage` instances.
        r
   r&   r
   r
   r   
run_checks   s    
zPanel.run_checksN)r   
__module____qualname____doc__r   propertyr   r   r   r   r   r   r   r"   r$   r%   classmethodr(   r)   r*   r/   r#   r5   r6   r7   r:   r;   r<   r
   r
   r
   r   r      sF   







	


	
r   N)Zdjango.template.loaderr   Zdebug_toolbarr   r   Zdebug_toolbar.utilsr   r   r
   r
   r
   r   <module>   s   