ó
‚•oTc           @   s€   d  d l  Z  d  d l 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(   iÿÿÿÿN(   t	   _cpconfigt
   _cploggingt
   _cprequestt   _cpwsgit   tools(   t   httpt   Applicationc           B   sä   e  Z e j Z d Z d  Z i  Z d Z	 e
 j ƒ  Z i e j d 6Z d Z d Z 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 „  Z" d „  Z# d „  Z$ RS(   s=  
    The top-most container of page handlers for this app. Handlers should
    be arranged in a hierarchy of attributes, matching the expected URI
    hierarchy; the default dispatcher then searches this hierarchy for a
    matching handler. When using a dispatcher other than the default,
    this value may be None.sc   
    A dict of {path: pathconf} pairs, where 'pathconf' is itself a dict
    of {key: value} pairs.R   s&   A LogManager instance. See _cplogging.s"   A CPWSGIApp instance. See _cpwsgi.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(    s$   /var/www/SABnzbd/cherrypy/_cptree.pyt   <lambda>7   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   s$   /var/www/SABnzbd/cherrypy/_cptree.pyt   __init__0   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   (    (    s$   /var/www/SABnzbd/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   s-   |  j  d  k r& t j j d j d ƒ S|  j  S(   Nt   SCRIPT_NAMEt   /(   t   _script_namet   NoneR   t   requestt   wsgi_environt   rstrip(   R   (    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyt   _get_script_nameR   s    c         C   s%   | r | j  d ƒ } n  | |  _ d  S(   NR"   (   R'   R#   (   R   t   value(    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyt   _set_script_nameW   s    t   fgett   fsett   docc         C   s3   t  j |  j | ƒ |  j |  j j d i  ƒ ƒ d  S(   NR"   (   R    R   R   R   t   get(   R   R   (    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyR   ^   s    c   	      C   s—   |  j  | | | | ƒ } |  | _ x* |  j j ƒ  D] \ } } | | j | <q1 W|  j ƒ  } t j j | | ƒ t j	 j
 j ƒ  t j	 j d ƒ | | f S(   Nt   acquire_thread(   t   request_classt   appt	   toolboxest	   iteritemsR   t   response_classR   t   servingt   loadt   enginet   timeout_monitort   acquiret   publish(	   R   t   localt   remotet   schemet   sprotot   reqt   namet   toolboxt   resp(    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyt   get_servinge   s    	c         C   s[   t  j j } t  j j j ƒ  y | j ƒ  Wn t  j d t d d ƒ n Xt  j j	 ƒ  d  S(   Nt	   tracebackt   severityi(   (
   R   R5   R%   R7   R8   t   releaset   closeR	   t   Truet   clear(   R   R?   (    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyt   release_servingt   s    c         C   s   |  j  | | ƒ S(   N(   R   (   R   t   environt   start_response(    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyt   __call__   s    N(%   R   R   R   t   _AttributeDocstringst   __metaclass__R$   R   t	   root__docR   t   config__docR    t   NamespaceSetR   R   R2   R	   t   log__docR   t   wsgiapp__docR   t   RequestR0   t   ResponseR4   t   Falset   relative_urlsR   R    t   script_name__docR(   R*   t   propertyR   R   RC   RJ   RM   (    (    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyR   	   s2   
										t   Treec           B   sM   e  Z i  Z d  Z d „  Z d d d „ Z d d „ Z d d „ Z d „  Z	 RS(   s  
    A dict of the form {script name: application}, where "script name"
    is a string declaring the URI mount point (no trailing slash), and
    "application" is an instance of cherrypy.Application (or an arbitrary
    WSGI callable if you happen to be using a WSGI server).c         C   s   i  |  _  d  S(   N(   t   apps(   R   (    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyR   ”   s    R   c         C   s  | d  k r t d ƒ ‚ n  | j d ƒ } t | t ƒ rr | } | d k rf | | j k rf 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(   Ns  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.ico(   R$   t	   TypeErrorR'   t
   isinstanceR   R   t
   ValueErrort   hasattrt   ost   patht   joint   getcwdt   dirnamet   __file__R   t
   staticfilet   handlerR]   R   R\   (   R   R   R   R   R1   t   favicon(    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyt   mount—   s&    !	c         C   s    | j  d ƒ } | |  j | <d  S(   NR"   (   R'   R\   (   R   t   wsgi_callableR   (    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyt   graftÉ   s    c         C   s   | d  k rF y" t j t j j t j j ƒ } WqF t k
 rB d  SXn  x@ t rˆ | |  j	 k rb | S| d k rr d  S| | j
 d ƒ  } qI Wd  S(   NR   R"   (   R$   t   _httpt   urljoinR   R%   R   t	   path_infot   AttributeErrorRH   R\   t   rfind(   R   Rc   (    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyR   Ï   s    	c         C   s©   t  j | j d d ƒ | j d d ƒ ƒ } |  j | p9 d ƒ } | d  k r\ | d g  ƒ g  S|  j | } | j ƒ  } | | d <| t | j d ƒ ƒ | d <| | | ƒ S(   NR!   R   t	   PATH_INFOR"   s   404 Not Found(	   Rn   Ro   R.   R   R$   R\   R   t   lenR'   (   R   RK   RL   Rc   t   snR1   (    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyRM   æ   s    
N(
   R   R   R\   t	   apps__docR   R$   Rk   Rm   R   RM   (    (    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyR[   …   s   	2(   Rb   R   R    R   R   R   R   t   cherrypy.libR   Rn   t   objectR   R[   (    (    (    s$   /var/www/SABnzbd/cherrypy/_cptree.pyt   <module>   s
   (|