%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib/python2.7/site-packages/paste/util/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib/python2.7/site-packages/paste/util/scgiserver.pyo

�
|��Wc@sfdZddlZddlZddlmZd�Zdejfd��YZdddd�Z	dS(sv
SCGI-->WSGI application proxy, "SWAP".

(Originally written by Titus Brown.)

This lets an SCGI front-end like mod_scgi be used to execute WSGI
application objects.  To use it, subclass the SWAP class like so::

   class TestAppHandler(swap.SWAP):
       def __init__(self, *args, **kwargs):
           self.prefix = '/canal'
           self.app_obj = TestAppClass
           swap.SWAP.__init__(self, *args, **kwargs)

where 'TestAppClass' is the application object from WSGI and '/canal'
is the prefix for what is served by the SCGI Web-server-side process.

Then execute the SCGI handler "as usual" by doing something like this::

   scgi_server.SCGIServer(TestAppHandler, port=4000).serve()

and point mod_scgi (or whatever your SCGI front end is) at port 4000.

Kudos to the WSGI folk for writing a nice PEP & the Quixote folk for
writing a nice extensible SCGI server for Python!
i����N(tscgi_servercCs?tjdtjtj���}tjjd||f�dS(Ns%Y-%m-%d %H:%M:%Ss[%s] %s
(ttimetstrftimet	localtimetsyststderrtwrite(tmsgt	timestamp((sF/opt/alt/python27/lib/python2.7/site-packages/paste/util/scgiserver.pytdebug s	tSWAPcBs,eZdZdZdZd�Zd�ZRS(s`
    SCGI->WSGI application proxy: let an SCGI server execute WSGI
    application objects.
    cOs$|f|}tjj||�dS(N(RtSCGIHandlert__init__(tselftargstkwargs((sF/opt/alt/python27/lib/python2.7/site-packages/paste/util/scgiserver.pyR-s
csC|jd�}|jd�}|j|�}||d<tj|d<d"|d<t|d<t|d	<t|d
<|jdd�d#kr�d|d<n
d|d<|j}|dt|�j	dd�d}||d<||d<g�g�g��fd��d���fd�}|j||�}z�x|D]}	�j|	�q1W�sid}
d$g}dg�n�\}
}�(|j
d|
�x|D]}|j
d|�q�W|j
d�x�D]}	|j
|	�q�WWdt|d �r�|j�nXy"|j�|j�|j�Wn!tk
r>}
td!|
�nXdS(%s2
        Handle an individual connection.
        trtws
wsgi.inputswsgi.errorsiiswsgi.versionswsgi.multithreadswsgi.multiprocesss
wsgi.run_oncetHTTPStofftont1thttpsswsgi.url_schemethttptREQUEST_URIt?tSCRIPT_NAMEt	PATH_INFOcs�j|�dS(N(tappend(tdata(tchunks(sF/opt/alt/python27/lib/python2.7/site-packages/paste/util/scgiserver.pyRUscs^|r8z%�r*|d|d|d�nWdd}Xn�rMtd��n||g�(�S(NiiisHeaders already set!(tNonetAssertionError(tstatustresponse_headerstexc_info(theaders_senttheaders_setR(sF/opt/alt/python27/lib/python2.7/site-packages/paste/util/scgiserver.pytstart_responseXs

s500 Server ErrorsContent-types	text/htmlsXXX start_response never calledsStatus: %s
s%s: %s
s
Ntcloses,IOError while closing connection ignored: %s(ii(RR(sContent-types	text/html(tmakefiletread_envRRtFalsetTruetgettprefixtlentsplitRtapp_objRRthasattrR'tIOErrorR	(R
tconntinputtoutputtenvironR-tpathR&tresultRR!R"theaderterr((RR$R%RsF/opt/alt/python27/lib/python2.7/site-packages/paste/util/scgiserver.pythandle_connection3sX







	$


	




N(t__name__t
__module__t__doc__RR0R-RR;(((sF/opt/alt/python27/lib/python2.7/site-packages/paste/util/scgiserver.pyR
%s
	cs}dtf��fd��Y}td|�}x5dD]-}t�|dk	r5t�|||<q5q5Wtj|�j�dS(	sV
    Serve the specified WSGI application via SCGI proxy.

    ``application``
        The WSGI application to serve.

    ``prefix``
        The prefix for what is served by the SCGI Web-server-side process.

    ``port``
        Optional port to bind the SCGI proxy to. Defaults to SCGIServer's
        default port value.

    ``host``
        Optional host to bind the SCGI proxy to. Defaults to SCGIServer's
        default host value.

    ``host``
        Optional maximum number of child processes the SCGIServer will
        spawn. Defaults to SCGIServer's default max_children value.
    tSCGIAppHandlercseZ��fd�ZRS(cs)�|_�|_tj|||�dS(N(R-R0R
R(R
RR(tapplicationR-(sF/opt/alt/python27/lib/python2.7/site-packages/paste/util/scgiserver.pyR�s		(R<R=R((R@R-(sF/opt/alt/python27/lib/python2.7/site-packages/paste/util/scgiserver.pyR?�st
handler_classthosttporttmax_childrenN(shostsportsmax_children(R
tdicttlocalsRRt
SCGIServertserve(R@R-RCRBRDR?Rtkwarg((R@R-sF/opt/alt/python27/lib/python2.7/site-packages/paste/util/scgiserver.pytserve_application�s
(
R>RRtscgiRR	RR
RRJ(((sF/opt/alt/python27/lib/python2.7/site-packages/paste/util/scgiserver.pyt<module>s	e

Zerion Mini Shell 1.0