ó
;
Dc           @   si   d  Z  d d l m Z m Z d d l Z d d l Z d e f d     YZ d   Z d   Z	 d   Z
 d S(	   sS   

This module is a mod_python handler that can be used to test the configuration.

iĸĸĸĸ(   t   apachet   utilNt   bounded_bufferc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s   
        This class implements a bounded buffer, i.e. a list that keeps the last
        n lines. It doesn't use pop(0), which is costly.
    
    c         C   s   | |  _  g  |  _ d |  _ d  S(   Ni    (   t   max_sizet   listt   pos(   t   selft   size(    (    s:   /usr/lib/python2.7/dist-packages/mod_python/testhandler.pyt   __init__#   s    		c         C   sV   t  |  j  |  j k  r+ |  j j |  n | |  j |  j <|  j d |  j |  _ d  S(   Ni   (   t   lenR   R   t   appendR   (   R   t   value(    (    s:   /usr/lib/python2.7/dist-packages/mod_python/testhandler.pyR
   (   s    c         C   s   |  j  |  j |  j  |  j  S(   N(   R   R   (   R   (    (    s:   /usr/lib/python2.7/dist-packages/mod_python/testhandler.pyt   items/   s    c         C   s   t  |  j    S(   N(   t   iterR   (   R   (    (    s:   /usr/lib/python2.7/dist-packages/mod_python/testhandler.pyt   __iter__2   s    (   t   __name__t
   __module__t   __doc__R   R
   R   R   (    (    (    s:   /usr/lib/python2.7/dist-packages/mod_python/testhandler.pyR      s
   			c         C   sW   |  j  d  |  j  d  x) | D]! } |  j  d | | | f  q! W|  j  d  d  S(   Ns   <table border="1">s$   <tr><th>Key</th><th>Value</th></tr>
s:   <tr><td><code>%s</code></td><td><code>%s</code></td></tr>
s   </table>(   t   write(   t   reqt   tablet   key(    (    s:   /usr/lib/python2.7/dist-packages/mod_python/testhandler.pyt   write_table5   s    	c         C   so   xh | D]` } t  | t  r3 t |  | | d  q |  j d |  |  j d j |   |  j d  q Wd  S(   Ni   s       t    s   
(   t
   isinstanceR   t
   write_treeR   t   join(   R   t   treet   levelt   entry(    (    s:   /usr/lib/python2.7/dist-packages/mod_python/testhandler.pyR   ?   s    c         C   s@  t  j |   |  _ |  j j d  r° t t j j t j	   |  j
 j  d  } t d  } x | D] } | j |  qa W| j   d |  _ x | D] } |  j |  q Wt j S|  j   d |  _ |  j d  |  j d  |  j d  |  j d	 d
 |  j j d  f  |  j d	 d t j t j  rAd t j t j  pDd f  |  j d	 d t j t j  rd t j t j  pd f  |  j d	 d t j	   f  |  j d	 d |  j   f  |  j
 j r|  j d d t j j t j	   |  j
 j  f  n |  j d	 d0  |  j d	 d t j f  |  j d d d j t j  f  |  j d	 d |  j f  |  j d  y! d d l m } |  j d  Wn |  j d   n X|  j d!  |  j d"  y! d d# l m  } |  j d  Wn |  j d   n X|  j d!  |  j d$  |  j d%  t! |  |  j"  |  j d&  t! |  |  j  |  j d'  t! |  |  j#    |  j d(  t! |  |  j$    |  j d)  t! |  |  j%  |  j d*  t! |  |  j
 j#    |  j d+  t! |  |  j
 j$    |  j d,  t& |  t j'   d-  |  j d.  |  j d/  t j S(1   Nt   view_logt   rbid   s
   text/plains	   text/htmls=   <html><head><title>mod_python test page</title></head><body>
s   <h3>General information</h3>
s   <table border="1">
s:   <tr><td><code>%s</code></td><td><code>%s</code></td></tr>
s   Apache versiont   SERVER_SOFTWAREs   Apache threaded MPMs!   Yes, maximum %i threads / processs   No (single thread MPM)s   Apache forked MPMs   Yes, maximum %i processess   No (single process MPM)s   Apache server roots   Apache document rootsx   <tr><td><code>%s</code></td><td><code>%s</code> (<a href="?view_log=1" target="_new">view last 100 lines</a>)</td></tr>
s   Apache error logt   Nones   Python sys.versions8   <tr><td><code>%s</code></td><td><pre>%s</pre></td></tr>
s   Python sys.paths   
s   Python interpreter namesB   <tr><td><code>mod_python.publisher available</code></td><td><code>iĸĸĸĸ(   t	   publishert   Yest   Nos   </code></td></tr>
s<   <tr><td><code>mod_python.psp available</code></td><td><code>(   t   psps	   </table>
s   <h3>Request input headers</h3>
s   <h3>Request environment</h3>
s   <h3>Request configuration</h3>
s   <h3>Request options</h3>
s   <h3>Request notes</h3>
s   <h3>Server configuration</h3>
s   <h3>Server options</h3>
s(   <h3>Server configuration tree</h3>
<pre>i    s   </pre>
s   </body></html>(   s   Apache error logs   None((   R   t   FieldStoraget   formt   getfirstt   filet   ost   pathR   R    t   server_roott   servert   error_fnameR   R
   t   closet   content_typeR   t   OKt   add_common_varst   subprocess_envt   gett	   mpm_queryt   AP_MPMQ_IS_THREADEDt   AP_MPMQ_MAX_THREADSt   AP_MPMQ_IS_FORKEDt   AP_MPMQ_MAX_DAEMONSt   document_roott   syst   versiont   interpretert
   mod_pythonR"   R%   R   t
   headers_int
   get_configt   get_optionst   notesR   t   config_tree(   R   t   logt   linest   lineR"   R%   (    (    s:   /usr/lib/python2.7/dist-packages/mod_python/testhandler.pyt   handlerH   sŪ    *
	
							)	 			(   R   R>   R    R   R;   R*   t   objectR   R   R   RG   (    (    (    s:   /usr/lib/python2.7/dist-packages/mod_python/testhandler.pyt   <module>   s   	
		