U
    7h                     @   s0   d dl Z d dlmZ e  Zde_dddZdS )    N)WSGIHandler  c                 C   s~   z.t |jjjdtr |t_ntjr,tj}W n tk
rB   Y nX z*|dkrT| }|j	|k	rh|
||W 5 d}d}X dS )a  
    Alternative function for django.views.debug.technical_500_response.

    Django's convert_exception_to_response() wrapper is called on each 'Middleware' object to avoid
    leaking exceptions. If an uncaught exception is raised, the wrapper calls technical_500_response()
    to create a response for django's debug view.

    Runserver_plus overrides the django debug view's technical_500_response() function to allow for
    an enhanced WSGI debugger view to be displayed. However, because Django calls
    convert_exception_to_response() on each object in the stack of Middleware objects, re-raising an
    error quickly pollutes the traceback displayed.

    Runserver_plus only needs needs traceback frames relevant to WSGIHandler Middleware objects, so
    only store the traceback if it is for a WSGIHandler. If an exception is not raised here, Django
    eventually throws an error for not getting a valid response object for its debug view.
    selfN)
isinstancetb_nexttb_framef_localsgetr   tldwsgi_tbAttributeError__traceback__with_traceback)requestexc_type	exc_valuetbstatus_code r   i/var/www/formularioweb/env/lib/python3.8/site-packages/django_extensions/management/technical_response.pynull_technical_500_response
   s    


r   )r   )	threadingZdjango.core.handlers.wsgir   localr
   r   r   r   r   r   r   <module>   s   