HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/__pycache__/_cptree.cpython-310.pyc
o

�N�g�*�@sddZddlZddlZddlmZmZmZmZmZddlm	Z	m
Z
Gdd�de�ZGdd�de�Z
dS)	z&CherryPy Application and Tree objects.�N)�	_cpconfig�
_cplogging�
_cprequest�_cpwsgi�tools)�httputil�reprconfc@s�eZdZdZdZ	iZ	e��Zde	j
iZdZ	dZ
	ejZejZdZddd�Zdd	�Zd
Zedd��Zejd
d��Zdd�Zddd�Zdd�Zdd�Zdd�ZdS)�ApplicationaA CherryPy Application.

    Servers and gateways should not instantiate Request objects directly.
    Instead, they should ask an Application object for a request object.

    An instance of this class may also be used as a WSGI callable
    (WSGI application object) for itself.
    NrF�cs~t�t��tjj��_|�_|�_t�	���_
�j���_�fdd��jd<�j
j
�jd<�jj���_|r=��|�dSdS)z'Initialize Application with given root.cst�j||�S�N)�setattr�log)�k�v��self��D/opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/_cptree.py�<lambda>5sz&Application.__init__.<locals>.<lambda>r
ZwsgiN)rZ
LogManager�id�cherrypyr
Zlogger_root�root�script_namerZ	CPWSGIApp�wsgiapp�
namespaces�copyZnamespace_handler�	__class__�config�merge)rrrrrrr�__init__-s�zApplication.__init__cCsd|j|jj|j|jfS)z6Generate a representation of the Application instance.z
%s.%s(%r, %r))�
__module__r�__name__rrrrrr�__repr__<s�zApplication.__repr__a�The URI "mount point" for this app. A mount point
    is that portion of the URI which is constant for all URIs that are
    serviced by this application; it does not include scheme, host, or proxy
    ("virtual host") portions of the URI.

    For example, if script_name is "/my/cool/app", then the URL
    "http://www.example.com/my/cool/app/page1" might be handled by a
    "page1" method on the root object.

    The value of script_name MUST NOT end in a slash. If the script_name
    refers to the root of the URI, it MUST be an empty string (not "/").

    If script_name is explicitly set to None, then the script_name will be
    provided for each call from request.wsgi_environ['SCRIPT_NAME'].
    cCs$|jdur|jStjjjd�d�S)a�The URI "mount point" for this app.

        A mount point is that portion of the URI which is constant for all URIs
        that are serviced by this application; it does not include scheme,
        host, or proxy ("virtual host") portions of the URI.

        For example, if script_name is "/my/cool/app", then the URL
        "http://www.example.com/my/cool/app/page1" might be handled by a
        "page1" method on the root object.

        The value of script_name MUST NOT end in a slash. If the script_name
        refers to the root of the URI, it MUST be an empty string (not "/").

        If script_name is explicitly set to None, then the script_name will be
        provided for each call from request.wsgi_environ['SCRIPT_NAME'].
        N�SCRIPT_NAME�/)�_script_namer�serving�requestZwsgi_environ�rstriprrrrrQs
zApplication.script_namecCs|r|�d�}||_dS)Nr$)r(r%)r�valuerrrrjs

cCs&t�|j|�|�|j�di��dS)z(Merge the given config into self.config.r$N)rrrr�get)rrrrrrpszApplication.mergecCsl|pd}|r4|j�|i�}||vr||S|�d�}|dkr!	|S|dkr,|dkr,d}n|d|�}|s|S)z>Return the most-specific value for key along path, or default.r$���rN)rr*�rfind)r�path�key�default�trailZnodeconfZ	lastslashrrr�find_configws
��zApplication.find_configc	Csj|�||||�}||_|j��D]	\}}||j|<q|��}tj�||�tj	�
d�tj	�
d�||fS)z0Create and return a Request and Response object.Zacquire_threadZbefore_request)�
request_class�app�	toolboxes�itemsr�response_classrr&�load�engine�publish)	r�localZremote�schemeZsproto�req�nameZtoolboxZresprrr�get_serving�szApplication.get_servingcCsPtjj}tj�d�z|��Wnty tjddd�Ynwtj��dS)z3Release the current serving (request and response).Z
after_requestT�()�	tracebackZseverityN)	rr&r'r8r9�close�	Exceptionr
�clear)rr<rrr�release_serving�s�zApplication.release_servingcCs|�||�S)zCall a WSGI-callable.)r)r�environ�start_responserrr�__call__�szApplication.__call__�r
Nr)r!r �__qualname__�__doc__rrrZNamespaceSetrrrr4r
rrZRequestr2ZResponser6Z
relative_urlsrr"Zscript_name_doc�propertyr�setterrr1r>rDrGrrrrr	
s6	





r	c@sDeZdZdZiZ	dd�Zddd�Zddd	�Zdd
d�Zdd
�Z	dS)�Treez�A registry of CherryPy applications, mounted at diverse points.

    An instance of this class may also be used as a WSGI callable
    (WSGI application object), in which case it dispatches to all
    mounted apps.
    cCs
i|_dS)zInitialize registry Tree.N)�appsrrrrr�s
z
Tree.__init__r
NcCs�|durtd��|�d�}t|t�r%|}|dkr!||jkr!td��|j}n*t||�}|dko7|duo7t|d�}|rOtj�	t�
�tj�t�d�}t
j�|�|_|rV|�|�||j|<|S)a�Mount a new app from a root object, script_name, and config.

        root
            An instance of a "controller class" (a collection of page
            handler methods) which represents the root of the application.
            This may also be an Application instance, or None if using
            a dispatcher other than the default.

        script_name
            A string containing the "mount point" of the application.
            This should start with a slash, and be the path portion of the
            URL at which to mount the given root. For example, if root.index()
            will handle requests to "http://www.example.com:8080/dept/app1/",
            then the script_name argument would be "/dept/app1".

            It MUST NOT end in a slash. If the script_name refers to the
            root of the URI, it MUST be an empty string (not "/").

        config
            A file or dict containing application config.
        NaThe 'script_name' argument may not be None. Application objects may, however, possess a script_name of None (in order to inpect the WSGI environ for SCRIPT_NAME upon each request). You cannot mount such Applications on this Tree; you must pass them to a WSGI server interface directly.r$r
zYCannot specify a different script name and pass an Application instance to cherrypy.mount�favicon_icozfavicon.ico)�	TypeErrorr(�
isinstancer	r�
ValueError�hasattr�osr-�join�getcwd�dirname�__file__rZ
staticfile�handlerrOrrN)rrrrr3Z
needs_faviconZfaviconrrr�mount�s:�

�
�
�
�

z
Tree.mountcCs|�d�}||j|<dS)z/Mount a wsgi callable at the given script_name.r$N)r(rN)rZ
wsgi_callablerrrr�graft�s
z
Tree.graftcCsj|durztjj}t�|j|j�}Wn
tyYdSw	||jvr%|S|dkr+dS|d|�	d��}q)zzReturn the script_name of the app at the given path, or None.

        If path is None, cherrypy.request is used.
        NTr
r$)
rr&r'r�urljoinrZ	path_info�AttributeErrorrNr,)rr-r'rrrrs ��
�zTree.script_namecCs�|}t�|�dd�|�dd��}|�|pd�}|dur"|dg�gS|j|}|��}||d<|t|�d��d�|d<|||�S)z/Pre-initialize WSGI env and call WSGI-callable.r#r
Z	PATH_INFOr$Nz
404 Not Found)rr\r*rrNr�lenr()rrErFZenv1xr-Zsnr3rrrrGs
�


z
Tree.__call__rH)r
r)
r!r rIrJrNrrZr[rrGrrrrrM�s

@
rM)rJrTrrrrrrZcherrypy.librr�objectr	rMrrrr�<module>s"