³ò
+e|Mc           @   sþ   d  Z  d d k Z d d k Z d d k Z d d k Z y d d k Z Wn e j
 o d Z n Xd d k l	 Z	 d d g Z
 d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d d d d „ Z d d d d „ Z d S(   s%   
Application that runs a CGI script.
iÿÿÿÿN(   t
   converterst   CGIErrort   CGIApplicationc           B   s   e  Z d  Z RS(   s`   
    Raised when the CGI script can't be found or doesn't
    act like a proper CGI script.
    (   t   __name__t
   __module__t   __doc__(    (    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyR      s   c           B   s)   e  Z d  Z d e d d „ Z d „  Z RS(   sý   
    This object acts as a proxy to a CGI application.  You pass in the
    script path (``script``), an optional path to search for the
    script (if the name isn't absolute) (``path``).  If you don't give
    a path, then ``$PATH`` will be used.
    c         C   sJ  | o t  d ƒ ‚ n | |  _ | d  j o" t i i d d ƒ i d ƒ } n | |  _ d | j o= | d  j p t d | | f ‚ | i d d ƒ \ } } n t i i	 | ƒ | j op xv |  i D]E } t i i
 t i i | | ƒ ƒ o t i i | | ƒ |  _ PqÅ qÅ Wt d | |  i f ƒ ‚ n
 | |  _ | |  _ | |  _ d  S(	   Nsj   global_conf is no longer supported for CGIApplication (use make_cgi_application); please pass None insteadt   PATHt    t   :t   ?sN   You cannot have '?' in your script name (%r) and also give a query_string (%r)i   s   Script %r not found in path %r(   t   NotImplementedt   script_filenamet   Nonet   ost   environt   gett   splitt   patht   AssertionErrort   abspatht   existst   joint   scriptR   t   include_os_environt   query_string(   t   selft   global_confR   R   R   R   t   path_dir(    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyt   __init__#   s0    	"	
 "			c   
      C   s  d | j o< t  i | i d d ƒ ƒ t  i | i d d ƒ ƒ | d <n |  i o t i i ƒ  } n h  } xG | D]? } | i ƒ  | j o& t | | t	 ƒ o | | | | <qs qs W|  i
 d  j	 o< | i d d ƒ } | o | d 7} n | |  i
 | d <n |  i | d <t i |  i g d t i d	 t i d
 t i d | d t i i |  i ƒ ƒ} t | | ƒ } t o= t i d j o- t | d t i | ƒ d	 | d
 | d ƒnN | i t i | ƒ i ƒ  ƒ \ } }	 |	 o | d i |	 ƒ n | i | ƒ | i p | | i | i ƒ n g  S(   Nt   REQUEST_URIt   SCRIPT_NAMER   t	   PATH_INFOt   QUERY_STRINGt   &t   SCRIPT_FILENAMEt   stdint   stdoutt   stderrt   envt   cwdt   win32s   wsgi.errors(   t   urllibt   quoteR   R   R   R   t   copyt   uppert
   isinstancet   strR   R   R   t
   subprocesst   Popent   PIPER   t   dirnamet	   CGIWritert   selectt   syst   platformt   proc_communicatet   StdinReadert   from_environt   communicatet   readt   writet   headers_finishedt   statust   headers(
   R   R   t   start_responset   cgi_environt   namet   oldt   proct   writerR$   R%   (    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyt   __call__E   sL    $
 			$
N(   R   R   R   R   t   TrueR   RF   (    (    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyR      s
   R3   c           B   s   e  Z d  „  Z d „  Z RS(   c         C   sC   | |  _  | |  _ d |  _ g  |  _ t |  _ d  |  _ d |  _ d  S(   Ns   200 OKR   (	   R   R@   R>   R?   t   FalseR=   R   RE   t   buffer(   R   R   R@   (    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyR   s   s    						c         C   s³  |  i  o |  i | ƒ d  Sn |  i | 7_ x~d |  i j omd |  i j oG |  i i d ƒ |  i i d ƒ j  o" |  i i d d ƒ \ } |  _ n |  i i d d ƒ \ } |  _ | pK t |  _  |  i |  i |  i ƒ |  _ |  i |  i ƒ |  ` |  ` |  ` Pq1 d | j o t	 d | ƒ ‚ q1 | i d d ƒ \ } } | i
 ƒ  } | i ƒ  } | i ƒ  d j o( d | j o d | } n | |  _ q1 |  i i | | f ƒ q1 Wd  S(	   Ns   
s   
i   R   s   Bad header line: %rR>   t    s
   %s General(   R=   RE   RI   t   findR   RG   R@   R>   R?   R   t   lstript   stript   lowert   append(   R   t   datat   line1RB   t   value(    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyR<   |   s:    
 5"	(   R   R   R   R<   (    (    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyR3   q   s   		R8   c           B   s2   e  Z d  „  Z d „  Z e e ƒ Z d d „ Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   R#   t   content_length(   R   R#   RS   (    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyR       s    	c         C   s=   | i  d ƒ } | o t | ƒ } n d } |  | d | ƒ S(   Nt   CONTENT_LENGTHi    s
   wsgi.input(   R   t   int(   t   clsR   t   length(    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyR9   ¤   s
    c         C   so   |  i  p d Sn | d  j o |  i i |  i  ƒ } n |  i i t |  i  | ƒ ƒ } |  i  t | ƒ 8_  | S(   NR   (   RS   R   R#   R;   t   mint   len(   R   t   sizet   text(    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyR;   ®   s    
N(   R   R   R   R9   t   classmethodR   R;   (    (    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyR8   ž   s   		c         C   s  g  } g  } d } |  i  o t t d ƒ } |  i o9 |  i i ƒ  t o | i |  i ƒ q‚ |  i i ƒ  n | d j p t	 ‚ |  i
 o | i |  i
 ƒ n | d j p t	 ‚ |  i o | i |  i ƒ n | d j p t	 ‚ xì| p | oÝt i | | g  ƒ \ } }	 }
 |  i |	 j o£ | d } } d t | ƒ } | o | | i | ƒ 7} n | p! |  i i ƒ  | i |  i ƒ qÈt i |  i i ƒ  | ƒ } | t | ƒ j  o | | } qÈn |  i
 | j ot t i |  i
 i ƒ  d ƒ } | d j o! |  i
 i ƒ  | i |  i
 ƒ n | o |  i | ƒ } n | i | ƒ n |  i | j ot t i |  i i ƒ  d ƒ } | d j o! |  i i ƒ  | i |  i ƒ n | o |  i | ƒ } n | i | ƒ qé qé Wy |  i ƒ  Wn, t j
 o  } | i d j o ‚  qn Xd S(   sf  
    Run the given process, piping input/output/errors to the given
    file-like objects (which need not be actual file objects, unlike
    the arguments passed to Popen).  Wait for process to terminate.

    Note: this is taken from the posix version of
    subprocess.Popen.communicate, but made more general through the
    use of file-like objects.
    R   t   newlinesi   i   i
   N(   t   universal_newlinest   hasattrt   openR#   t   flusht   inputRO   t   closeR   R   R$   R%   R4   RY   R;   t   removeR   R<   t   filenot   _translate_newlinest   waitt   OSErrort   errno(   RD   R#   R$   R%   t   read_sett	   write_sett   input_buffert   trans_nlt   rlistt   wlistt   xlistt   nextt   next_lent   bytes_writtenRP   t   e(    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyR7   ¸   sf    



 c         C   s[   | d j o# |  i d ƒ p |  i d ƒ } n t i | ƒ } t | d | d | d | ƒS(   s5  
    Paste Deploy interface for :class:`CGIApplication`

    This object acts as a proxy to a CGI application.  You pass in the
    script path (``script``), an optional path to search for the
    script (if the name isn't absolute) (``path``).  If you don't give
    a path, then ``$PATH`` will be used.
    R   R   R   R   N(   R   R   R    t   asboolR   (   R   R   R   R   R   (    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pyt   make_cgi_application  s    
#(   R   R   R5   R/   R)   R4   t   ImportErrorR   t
   paste.utilR    t   __all__t	   ExceptionR   t   objectR   R3   R8   R7   Rv   (    (    (    s[   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/cgiapp.pys   <module>   s"   W-M