
    \d                         d Z dZddlmZ ddlmZ ddlmZmZ ddl	m
Z
mZ ddlmZmZ  G d d	e          Zd
ededede
fdZ	 	 ddedede
fdZ	 ddedede
fdZdS )z*
Utility implementations of L{IResource}.
)	errorPagenotFound	forbidden    )cast)http)IRenderableIRequest)	IResourceResource)renderElementtagsc                   X     e Zd ZdZdedededdf fdZdedefd	Z	d
e
dedefdZ xZS )
_ErrorPagea!  
    L{_ErrorPage} is a resource that responds to all requests with a particular
    (parameterized) HTTP status code and an HTML body containing some
    descriptive text. This is useful for rendering simple error pages.

    @see: L{twisted.web.pages.errorPage}

    @ivar _code: An integer HTTP status code which will be used for the
        response.

    @ivar _brief: A short string which will be included in the response body as
        the page title.

    @ivar _detail: A longer string which will be included in the response body.
    codebriefdetailreturnNc                 r    t                                                       || _        || _        || _        d S )N)super__init___code_brief_detail)selfr   r   r   	__class__s       1lib/python3.11/site-packages/twisted/web/pages.pyr   z_ErrorPage.__init__(   s2    
 "    requestc                    |                     | j                   |                    dd           t          |t	          t
          t          j        t          j        t          j	        | j         d| j
                             t          j        t          j        | j
                  t          j        | j                                                          S )z
        Respond to all requests with the given HTTP status code and an HTML
        document containing the explanatory strings.
        s   content-types   text/html; charset=utf-8z - )setResponseCoder   	setHeaderr   r   r   r   htmlheadtitler   bodyh1pr   )r   r   s     r   renderz_ErrorPage.render.   s    
 	
+++/+FGGG 	IdjDJ)H)H4;)H)HIIJJIdgdk22DF4<4H4HII  
 
 	
r   pathc                     | S )z
        Handle all requests for which L{_ErrorPage} lacks a child by returning
        this error page.

        @param path: A path segment.

        @param request: HTTP request
         )r   r)   r   s      r   getChildz_ErrorPage.getChildC   s	     r   )__name__
__module____qualname____doc__intstrr   r	   objectr(   bytesr   r,   __classcell__)r   s   @r   r   r      s          #S # #c #d # # # # # #
h 
6 
 
 
 
*	U 	X 	( 	 	 	 	 	 	 	 	r   r   r   r   r   r   c                 $    t          | ||          S )au  
    Build a resource that responds to all requests with a particular HTTP
    status code and an HTML body containing some descriptive text. This is
    useful for rendering simple error pages.

    The resource dynamically handles all paths below it. Use
    L{IResource.putChild()} override specific path.

    @param code: An integer HTTP status code which will be used for the
        response.

    @param brief: A short string which will be included in the response
        body as the page title.

    @param detail: A longer string which will be included in the
        response body.

    @returns: An L{IResource}
    )r   )r   r   r   s      r   r   r   O   s    ( dE6***r   No Such Resource%Sorry. No luck finding that resource.messagec                 8    t          t          j        | |          S )a  
    Generate an L{IResource} with a 404 Not Found status code.

    @see: L{twisted.web.pages.errorPage}

    @param brief: A short string displayed as the page title.

    @param brief: A longer string displayed in the page body.

    @returns: An L{IResource}
    )r   r   	NOT_FOUNDr   r9   s     r   r   r   f   s     dneW555r   Forbidden ResourceSorry, resource is forbidden.c                 8    t          t          j        | |          S )a  
    Generate an L{IResource} with a 403 Forbidden status code.

    @see: L{twisted.web.pages.errorPage}

    @param brief: A short string displayed as the page title.

    @param brief: A longer string displayed in the page body.

    @returns: An L{IResource}
    )r   r   	FORBIDDENr<   s     r   r   r   x   s     dneW555r   N)r7   r8   )r=   r>   )r0   __all__typingr   twisted.webr   twisted.web.iwebr   r	   twisted.web.resourcer
   r   twisted.web.templater   r   r   r1   r2   r   r   r   r+   r   r   <module>rG      s[  
              2 2 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 45 5 5 5 5 5 5 5p+C + +S +Y + + + +0 $:6 666 6 6 6 6& 7V6 660366 6 6 6 6 6r   