
^Q\                 @   s   d  d l  m Z m Z d  d l Z d  d l m Z d  d l m Z d  d l	 m
 Z
 Gd d   d e  Z Gd d	   d	 e  Z d S)
    )absolute_importunicode_literalsN)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 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& S)'Panelz 
    Base class for panels.
    c             C   s   | |  _  d  S)N)toolbar)selfr    r
   Q/var/www/dbchiro/venv/build/django-debug-toolbar/debug_toolbar/panels/__init__.py__init__   s    zPanel.__init__c             C   s
   |  j  j S)N)	__class____name__)r	   r
   r
   r   panel_id   s    zPanel.panel_idc             C   s{   t  j   d } t |   } | | k p= | j d d  | k } | rO d } n d } |  j 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`.
        )title)r	   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_subtitle4   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
   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)NotImplementedError)r	   r
   r
   r   r   C   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`.
        N)r   )r	   r
   r
   r   templateL   s    zPanel.templatec             C   s#   |  j  r t |  j |  j    Sd 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_stats)r	   r
   r
   r   contentV   s    		zPanel.contentc             C   s   g  S)zE
        Return URLpatterns, if the panel has its own views.
        r
   )clsr
   r
   r   get_urlsd   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 :class:`DebugToolbarMiddleware.process_request`. It
        should be idempotent.
        Nr
   )r	   r
   r
   r   enable_instrumentationm   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 :class:`DebugToolbarMiddleware.process_response`. It
        should be idempotent.
        Nr
   )r	   r
   r
   r   disable_instrumentation{   s    zPanel.disable_instrumentationc             C   s&   |  j  j j |  j i   j |  d S)z
        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 |  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 S)z
        Like process_request in Django's middleware.

        Write panel logic related to the request there. Save data with
        :meth:`record_stats`.
        Nr
   )r	   r   r
   r
   r   process_request   s    zPanel.process_requestc             C   s   d S)z
        Like process_view in Django's middleware.

        Write panel logic related to the view there. Save data with
        :meth:`record_stats`.
        Nr
   )r	   r   Z	view_funcZ	view_argsZview_kwargsr
   r
   r   process_view   s    zPanel.process_viewc             C   s   d S)aS  
        Like process_response in Django's middleware. This is similar to
        :meth:`generate_stats <debug_toolbar.panels.Panel.generate_stats>`,
        but will be executed on every request. It should be used when either
        the logic needs to be executed on every request or it needs to change
        the response entirely, such as :class:`RedirectsPanel`.

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

        Return a response to overwrite the existing response.
        Nr
   )r	   r   responser
   r
   r   process_response   s    zPanel.process_responsec             C   s   d S)a  
        Similar to :meth:`process_response
        <debug_toolbar.panels.Panel.process_response>`,
        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   r,   r
   r
   r   generate_stats   s    zPanel.generate_statsN)r   
__module____qualname____doc__r   propertyr   r   r   r   r   r   r   r!   classmethodr#   r$   r%   r)   r    r*   r+   r-   r.   r
   r
   r
   r   r      s&   	
	r   c                   s"   e  Z d  Z   f d d   Z   S)
DebugPanelc                s-   t  j d t  t t |   j | |   d  S)Nz DebugPanel was renamed to Panel.)warningswarnDeprecationWarningsuperr4   r   )r	   argskwargs)r   r
   r   r      s    zDebugPanel.__init__)r   r/   r0   r   r
   r
   )r   r   r4      s   r4   )
__future__r   r   r5   Zdjango.template.loaderr   Zdebug_toolbarr   r   Zdebug_toolbar.utilsr   objectr   r4   r
   r
   r
   r   <module>   s   