ó
Xé?_c           @   sœ   d  Z  d d l Z d d l Z d d l m Z m Z d d l m Z m Z m Z m	 Z	 m
 Z
 d d l m Z d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ d S(
   s&   CherryPy Application and Tree objects.iÿÿÿÿN(   t   ntout   py3k(   t	   _cpconfigt
   _cploggingt
   _cprequestt   _cpwsgit   tools(   t   httputilt   Applicationc           B   sÕ   e  Z d  Z d Z i  Z e j ƒ  Z i e	 j
 d 6Z d Z d Z e j Z e j Z e Z d d d „ Z d „  Z d Z d „  Z d „  Z e d e d	 e d
 e ƒ Z d „  Z d d „ Z d „  Z d „  Z d „  Z  RS(   s  A 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.
    R   t    c            s¯   t  j t ˆ  ƒ t j j ƒ ˆ  _ | ˆ  _ | ˆ  _ t j	 ˆ  ƒ ˆ  _
 ˆ  j j ƒ  ˆ  _ ‡  f d †  ˆ  j d <ˆ  j
 j ˆ  j d <ˆ  j j j ƒ  ˆ  _ | r« ˆ  j | ƒ n  d  S(   Nc            s   t  ˆ  j |  | ƒ S(   N(   t   setattrt   log(   t   kt   v(   t   self(    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyt   <lambda>6   s    R   t   wsgi(   R   t
   LogManagert   idt   cherrypyR   t   logger_roott   roott   script_nameR   t	   CPWSGIAppt   wsgiappt
   namespacest   copyt   namespace_handlert	   __class__t   configt   merge(   R   R   R   R   (    (   R   sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyt   __init__/   s    !		c         C   s#   d |  j  |  j j |  j |  j f S(   Ns   %s.%s(%r, %r)(   t
   __module__R   t   __name__R   R   (   R   (    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyt   __repr__=   s    sÅ  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'].
    c         C   s0   |  j  d  k	 r |  j  St j j j d j d ƒ S(   Nt   SCRIPT_NAMEt   /(   t   _script_namet   NoneR   t   servingt   requestt   wsgi_environt   rstrip(   R   (    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyt   _get_script_nameQ   s    c         C   s%   | r | j  d ƒ } n  | |  _ d  S(   NR$   (   R*   R%   (   R   t   value(    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyt   _set_script_nameY   s    t   fgett   fsett   docc         C   s3   t  j |  j | ƒ |  j |  j j d i  ƒ ƒ d S(   s(   Merge the given config into self.config.R$   N(   R   R   R   R   t   get(   R   R   (    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyR   `   s    c         C   s   | p	 d } x} | r‹ |  j  j | i  ƒ } | | k r> | | S| j d ƒ } | d k r] Pq | d k r~ | d k r~ d } q | |  } q W| S(   s>   Return the most-specific value for key along path, or default.R$   iÿÿÿÿi    (   R   R1   t   rfind(   R   t   patht   keyt   defaultt   trailt   nodeconft	   lastslash(    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyt   find_configg   s    		c   	      C   s—   |  j  | | | | ƒ } |  | _ x* |  j j ƒ  D] \ } } | | j | <q1 W|  j ƒ  } t j j | | ƒ t j	 j
 d ƒ t j	 j
 d ƒ | | f S(   s0   Create and return a Request and Response object.t   acquire_threadt   before_request(   t   request_classt   appt	   toolboxest   itemsR   t   response_classR   R'   t   loadt   enginet   publish(	   R   t   localt   remotet   schemet   sprotot   reqt   namet   toolboxt   resp(    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyt   get_servingz   s    	c         C   s[   t  j j } t  j j d ƒ y | j ƒ  Wn t  j d t d d ƒ n Xt  j j ƒ  d S(   s3   Release the current serving (request and response).t   after_requestt	   tracebackt   severityi(   N(	   R   R'   R(   RB   RC   t   closeR   t   Truet   clear(   R   RH   (    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyt   release_serving‰   s    c         C   s   |  j  | | ƒ S(   N(   R   (   R   t   environt   start_response(    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyt   __call__–   s    N(!   R!   R    t   __doc__R&   R   R   R   t   NamespaceSetR   R   R   R>   R   R   R   t   RequestR<   t   ResponseR@   t   Falset   relative_urlsR   R"   t   script_name_docR+   R-   t   propertyR   R   R9   RL   RS   RV   (    (    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyR      s,   										t   Treec           B   sM   e  Z d  Z i  Z d „  Z d d d „ Z d d „ Z d d „ Z d „  Z	 RS(   sÛ   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.
    c         C   s   i  |  _  d  S(   N(   t   apps(   R   (    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyR   ª   s    R	   c         C   s  | d k r t d ƒ ‚ n  | j d ƒ } t | t ƒ ru | } | d k ri | | j k ri t d ƒ ‚ n  | j } ny t | | ƒ } | d k rî | d k	 rî t | d ƒ rî t j	 j
 t j ƒ  t j	 j t ƒ d ƒ } t j j | ƒ | _ n  | r| j | ƒ n  | |  j | <| S(   s·  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.
        s  The '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	   sY   Cannot specify a different script name and pass an Application instance to cherrypy.mountt   favicon_icos   favicon.icoN(   R&   t	   TypeErrorR*   t
   isinstanceR   R   t
   ValueErrort   hasattrt   osR3   t   joint   getcwdt   dirnamet   __file__R   t
   staticfilet   handlerRa   R   R`   (   R   R   R   R   R=   t   favicon(    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyt   mount­   s(    !	c         C   s    | j  d ƒ } | |  j | <d S(   s/   Mount a wsgi callable at the given script_name.R$   N(   R*   R`   (   R   t   wsgi_callableR   (    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyt   graftæ   s    c         C   s“   | d k rL y( t j j } t j | j | j ƒ } WqL t k
 rH d SXn  x@ t	 rŽ | |  j
 k rh | S| d k rx d S| | j d ƒ  } qO Wd S(   ss   The script_name of the app at the given path, or None.

        If path is None, cherrypy.request is used.
        R	   R$   N(   R&   R   R'   R(   R   t   urljoinR   t	   path_infot   AttributeErrorRQ   R`   R2   (   R   R3   R(   (    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyR   ì   s    	c         C   s  | } | j  t d ƒ ƒ t d ƒ d f k r? t j | ƒ } n  t j | j  d d ƒ | j  d d ƒ ƒ } |  j | px d ƒ } | d  k r› | d g  ƒ g  S|  j | } | j	 ƒ  } t
 sc| j  t d ƒ ƒ t d ƒ d f k r9| t d	 ƒ } | j | ƒ | t d ƒ <| t | j d ƒ ƒ j | ƒ | t d ƒ <qÿ| | d <| t | j d ƒ ƒ | d <nœ | j  t d ƒ ƒ t d ƒ d f k r´| | d <| t | j d ƒ ƒ | d <nK | j d
 ƒ j d ƒ | d <| t | j d ƒ ƒ j d
 ƒ j d ƒ | d <| | | ƒ S(   Ns   wsgi.versiont   ui    R#   R	   t	   PATH_INFOR$   s   404 Not Founds   wsgi.url_encodings   utf-8s
   ISO-8859-1(   R1   R    R   t   downgrade_wsgi_ux_to_1xR   Rq   R   R&   R`   R   R   t   decodet   lenR*   t   encode(   R   RT   RU   t   env1xR3   t   snR=   t   enc(    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyRV     s6    '',
 '
 ,N(
   R!   R    RW   R`   R   R&   Rn   Rp   R   RV   (    (    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyR_   š   s   	9(   RW   Rf   R   t   cherrypy._cpcompatR    R   R   R   R   R   R   t   cherrypy.libR   t   objectR   R_   (    (    (    sw   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cptree.pyt   <module>   s   (