
    ]j                         d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZmZ dd	lmZ dd
lmZ ddlmZ  G d d      ZdZej1                         Zy)zA
The main DebugToolbar class that loads and renders the Toolbar.
    N)OrderedDict)apps)ImproperlyConfigured)TemplateSyntaxError)render_to_string)pathresolve)Resolver404)import_string)settingsc                       e Zd Zd Zed        Zed        Zd Zd Zd Z	 e
       Zd Zed        Zd	Zed
        Zd	Zed        Zed        Zy	)DebugToolbarc                    || _         t        j                         j                         | _        g }t        | j                               D ]5  } || |      }|j                  |       |j                  s*|j                  }7 || _	        t               | _        |r,|j                         }|| j                  |j                  <   |r,i | _        i | _        d | _        y N)requestdt_settings
get_configcopyconfigreversedget_panel_classesappendenabledprocess_requestr   _panelspoppanel_idstatsserver_timing_statsstore_id)selfr   get_responsepanelspanel_classpanels         ?/root/env/lib/python3.12/site-packages/debug_toolbar/toolbar.py__init__zDebugToolbar.__init__   s    !,,.335#D$:$:$<= 	5Kl3EMM% }}$44		5
  ,"}JJLE+0DLL(  
#%     c                 H    t        | j                  j                               S )z5
        Get a list of all available panels.
        )listr   values)r!   s    r&   r#   zDebugToolbar.panels(   s    
 DLL'')**r(   c                 v    | j                   j                         D cg c]  }|j                  s| c}S c c}w )zG
        Get a list of panels enabled for the current request.
        )r   r+   r   )r!   r%   s     r&   enabled_panelszDebugToolbar.enabled_panels/   s+    
 $(<<#6#6#8J%EMMJJJs   66c                      | j                   |   S )zV
        Get the panel with the given id, which is the class name by default.
        )r   )r!   r   s     r&   get_panel_by_idzDebugToolbar.get_panel_by_id6   s     ||H%%r(   c                     | j                         s| j                          	 d| i}t        d|      S # t        $ r" t	        j
                  d      st        d       w xY w)zA
        Renders the overall Toolbar with panels inside.
        toolbarzdebug_toolbar/base.htmlzdjango.contrib.staticfileszThe debug toolbar requires the staticfiles contrib app. Add 'django.contrib.staticfiles' to INSTALLED_APPS and define STATIC_URL in your settings.)should_render_panelsstorer   r   r   is_installedr   )r!   contexts     r&   render_toolbarzDebugToolbar.render_toolbar>   sk     ((*JJL	 $'G#$=wGG" 	$$%AB*:  	s	   2 +Ac                 Z    | j                   d   }|| j                  j                  d   }|S )NRENDER_PANELSzwsgi.multiprocess)r   r   META)r!   render_panelss     r&   r2   z!DebugToolbar.should_render_panelsQ   s1    O4  LL--.ABMr(   c                 0   | j                   ry t        j                         j                  | _         | | j                  | j                   <   t        | j                  d   t        | j                              D ]  }| j                  j                  d         y )NRESULTS_CACHE_SIZEF)last)	r    uuiduuid4hex_storeranger   lenpopitem)r!   _s     r&   r3   zDebugToolbar.store[   so    ==

((%)DMM"t{{#78#dkk:JK 	,AKKU+	,r(   c                 8    | j                   j                  |      S r   )rA   get)clsr    s     r&   fetchzDebugToolbar.fetchd   s    zz~~h''r(   Nc                     | j                   1t        j                         D cg c]  }t        |       }}|| _         | j                   S c c}w r   )_panel_classesr   
get_panelsr   )rH   
panel_pathpanel_classess      r&   r   zDebugToolbar.get_panel_classesm   sT    % =H<R<R<T.8j)M  "/C!!!	s   A
c                     | j                   Nddlm} t        d|j                  d      g}| j                         D ]  }||j                         z  } || _         | j                   S )N   )viewszrender_panel/render_panel)name)_urlpatterns rQ   r   rR   r   get_urls)rH   rQ   urlpatternsr$   s       r&   rV   zDebugToolbar.get_urlsy   sm    #
 _e&8&8~NK  #446 6{33556*Cr(   c                     	 |j                   xs t        |j                        }|j                  xr |j                  d   t
        k(  S # t        $ r Y yw xY w)zF
        Determine if the request is for a DebugToolbar view.
        F)resolver_matchr	   r   r
   
namespacesapp_name)rH   r   rZ   s      r&   is_toolbar_requestzDebugToolbar.is_toolbar_request   sW    	$33Lww||7LN ((V^-F-Fr-Jh-VV  		s   #A	 		AA)__name__
__module____qualname__r'   propertyr#   r-   r/   r6   r2   r   rA   r3   classmethodrI   rK   r   rT   rV   r]    r(   r&   r   r      s    ( + + K K&& ]F, ( ( N" " L    
W 
Wr(   r   djdt)__doc__r>   collectionsr   django.appsr   django.core.exceptionsr   django.templater   django.template.loaderr   django.urlsr   r	   django.urls.exceptionsr
   django.utils.module_loadingr   debug_toolbarr   r   r   r\   rV   rW   rc   r(   r&   <module>ro      sN     #  7 / 3 % . 5 1AW AWH ##%r(   