%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/227033/root/opt/alt/python27/lib/python2.7/site-packages/paste/
Upload File :
Create Path :
Current File : //proc/227033/root/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyc

�
b�Nc@s�dZddlZddlZddlmZddlmZddlmZm	Z	m
Z
mZddlm
Z
mZddlmZddlmZdd	lmZdd
lmZddlmZdd
gZejdej�Zdefd��YZede��Zde fd��YZ!de fd��YZ"d
e fd��YZ#i*dd6dd6dd6dd6dd6d d!6d"d#6d$d%6d&d'6d(d)6d*d+6d,d-6d.d/6d0d16d2d36d4d56d6d76d8d96d:d;6d<d=6d>d?6d@dA6dBdC6dDdE6dFdG6dHdI6dJdK6dLdM6dNdO6dPdQ6dRdS6dTdU6dVdW6dXdY6dZd[6d\d]6d^d_6d`da6dbdc6ddde6dfdg6dhdi6Z$dS(js�WSGI Wrappers for a Request and Response

The WSGIRequest and WSGIResponse objects are light wrappers to make it easier
to deal with an incoming request and sending a response.
i����N(tpformat(tSimpleCookie(tEnvironHeaderstget_cookie_dicttparse_dict_querystringtparse_formvars(t	MultiDicttUnicodeMultiDict(tStackedObjectProxy(t
HeaderDict(tencode_unicode_app_iter(tACCEPT_LANGUAGE(tdesired_matchestWSGIRequesttWSGIResponses;\s*charset=([^;]*)tDeprecatedSettingscBseZd�ZRS(cCs7tjdtd�tjj|�tj||�dS(Nsepaste.wsgiwrappers.settings is deprecated: Please use paste.wsgiwrappers.WSGIRequest.defaults insteadi(twarningstwarntDeprecationWarningRtdefaultst_push_objectR(tselftobj((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyRs	
(t__name__t
__module__R(((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyRstdefaulttenviron_gettercBs2eZdZddd�Zdd�Zd�ZRS(s5For delegating an attribute to a key in self.environ.tcCs||_||_||_dS(N(tkeyRtdefault_factory(RRRR((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt__init__'s		cCsa|dkr|S|j|jkrS|jrI|j�}|j|j<|S|jSn|j|jS(N(tNoneRtenvironRR(RRttypetval((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt__get__+s	
cCsd|jS(Ns<Proxy for WSGI environ %r key>(R(R((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt__repr__6sN(RRt__doc__RRR#R$(((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyR$scBs�eZdZededddddedd��Zd�Ze	d	�Z
e	d
�Ze	d�Ze	d�Z
e	d
�Zd�Zeedej�Zd�Zeedej�Zd�Zeedej�Zd�Zeedej�Zd�Zd�Zeedej�Zd�Zd�Zeedej�Zd�Zeedej�Zd�Zeedej�Zd�Zd�Zd�ZRS(s#WSGI Request API Object

    This object represents a WSGI request with a more friendly interface.
    This does not expose every detail of the WSGI environment, and attempts
    to express nothing beyond what is available in the environment
    dictionary.

    The only state maintained in this object is the desired ``charset``,
    its associated ``errors`` handler, and the ``decode_param_names``
    option.

    The incoming parameter values will be automatically coerced to unicode
    objects of the ``charset`` encoding when ``charset`` is set. The
    incoming parameter names are not decoded to unicode unless the
    ``decode_param_names`` option is enabled.

    When unicode is expected, ``charset`` will overridden by the the
    value of the ``Content-Type`` header's charset parameter if one was
    specified by the client.

    The class variable ``defaults`` specifies default values for
    ``charset``, ``errors``, and ``langauge``. These can be overridden for the
    current request via the registry.
        
    The ``language`` default value is considered the fallback during i18n
    translations to ensure in odd cases that mixed languages don't occur should
    the ``language`` file contain the string but not another language in the
    accepted languages list. The ``language`` value only applies when getting
    a list of accepted languages from the HTTP Accept header.
    
    This behavior is duplicated from Aquarium, and may seem strange but is
    very useful. Normally, everything in the code is in "en-us".  However, 
    the "en-us" translation catalog is usually empty.  If the user requests
    ``["en-us", "zh-cn"]`` and a translation isn't found for a string in
    "en-us", you don't want gettext to fallback to "zh-cn".  You want it to 
    just use the string itself.  Hence, if a string isn't found in the
    ``language`` catalog, the string in the source code will be used.

    *All* other state is kept in the environment dictionary; this is
    essential for interoperability.

    You are free to subclass this object.

    Rtcharsetterrorstreplacetdecode_param_namestlanguagesen-uscCs�||_t|�|_|jj�}|jd�|_|jrc|j�}|rc||_qcn|jdd�|_|jdt	�|_
d|_dS(NR&R'tstrictR)(
R RtheadersRt_current_objtgetR&tdetermine_browser_charsetR'tFalseR)Rt
_languages(RR Rtbrowser_charset((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyRis		s
wsgi.inputswsgi.url_schemetREQUEST_METHODtSCRIPT_NAMEt	PATH_INFOcCs@d|jkr|jdSd|jkr8|jddSiSdS(sc
        Return any variables matched in the URL (e.g.,
        ``wsgiorg.routing_args``).
        s
paste.urlvarsswsgiorg.routing_argsiN(R (R((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyturlvars�s
tdoccCs|jjdd�dkS(sEReturns a boolean if X-Requested-With is present and a XMLHttpRequesttHTTP_X_REQUESTED_WITHRtXMLHttpRequest(R R.(R((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytis_xhr�scCs|jjd|jjd��S(s>Host name provided in HTTP_HOST, with fall-back to SERVER_NAMEt	HTTP_HOSTtSERVER_NAME(R R.(R((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pythost�scCs�|jdk	r|jS|jjd�}tj|j�}|jjdd�}|sY|S||kru|j|�n|j|�}g||d)||_|jS(slReturn a list of preferred languages, most preferred first.
        
        The list may be empty.
        tHTTP_ACCEPT_LANGUAGER*sen-usiN(	R1RR R.RtparseRtappendtindex(RtacceptLanguagetlangstfallbackRA((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt	languages�s	cCs
t|j�S(N(RR (R((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt_GET�scCsC|j�}|jr?t|d|jd|jd|j�}n|S(s�
        Dictionary-like object representing the QUERY_STRING
        parameters. Always present, if possibly empty.

        If the same key is present in the query string multiple times, a
        list of its values can be retrieved from the ``MultiDict`` via
        the ``getall`` method.

        Returns a ``MultiDict`` container or a ``UnicodeMultiDict`` when
        ``charset`` is set.
        tencodingR'tdecode_keys(RFR&RR'R)(Rtparams((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytGET�s		cCst|jdt�S(Ntinclude_get_vars(RR R0(R((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt_POST�scCsC|j�}|jr?t|d|jd|jd|j�}n|S(skDictionary-like object representing the POST body.

        Most values are encoded strings, or unicode strings when
        ``charset`` is set. There may also be FieldStorage objects
        representing file uploads. If this is not a POST request, or the
        body is not encoded fields (e.g., an XMLRPC request) then this
        will be empty.

        This will consume wsgi.input when first accessed if applicable,
        but the raw version will be put in
        environ['paste.parsed_formvars'].

        Returns a ``MultiDict`` container or a ``UnicodeMultiDict`` when
        ``charset`` is set.
        RGR'RH(RLR&RR'R)(RRI((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytPOST�s		cCsft�}|j|j��|j|j��|jrbt|d|jd|jd|j�}n|S(s�Dictionary-like object of keys from POST, GET, URL dicts

        Return a key value from the parameters, they are checked in the
        following order: POST, GET, URL

        Additional methods supported:

        ``getlist(key)``
            Returns a list of all the values by that key, collected from
            POST, GET, URL dicts

        Returns a ``MultiDict`` container or a ``UnicodeMultiDict`` when
        ``charset`` is set.
        RGR'RH(RtupdateRLRFR&RR'R)(RRI((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyRI�s			cCs
t|j�S(szDictionary of cookies keyed by cookie name.

        Just a plain dictionary, may be empty but not None.
        
        (RR (R((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytcookies�scCs5tj|jjdd��}|r1|jd�SdS(s�
        Determine the encoding as specified by the browser via the
        Content-Type's charset parameter, if one is set
        sContent-TypeRiN(t_CHARSET_REtsearchR,R.tgroup(Rt
charset_match((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyR/�scCst||jjdd��S(sqReturn a list of specified mime-types that the browser's HTTP Accept
        header allows in the order provided.tHTTP_ACCEPTs*/*(RR R.(Rt	mimetypes((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytmatch_acceptscCst}d|jj|jjt|�||j�f}|d||j�||j�||j�||j	�f7}|d||j
�7}|jr�|d||j�||j�f7}n|d||j
�7}|d||j�7}|d||j�7}|S(s,Show important attributes of the WSGIRequests <%s.%s object at 0x%x method=%s,s2
scheme=%s, host=%s, script_name=%s, path_info=%s,s
languages=%s,s charset=%s, errors=%s,s
GET=%s,s	
POST=%s,s
cookies=%s>(Rt	__class__RRtidtmethodtschemeR=tscript_namet	path_infoRER&R'RJRMRO(Rtpftmsg((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyR$s$	N(RRR%RtdictRR0RRRtbodyRZRYR[R\R6tpropertyR:R=RERFRJRLRMRIROR/RVR$(((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyR
9s>,														c
Bs\eZdZededddddddid	d
6��Zdd$dd
�Zd�Zd�Z	d�Z
d�Zdd$d$dd$d$d$d�Zdd$d�Z
d�Zed�edd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �Zeeeedej�Zd!�Zd"�Zd#�Zeeeedej�ZRS(%sA basic HTTP response with content, headers, and out-bound cookies

    The class variable ``defaults`` specifies default values for
    ``content_type``, ``charset`` and ``errors``. These can be overridden
    for the current request via the registry.

    Rtcontent_types	text/htmlR&sutf-8R'R+R,sno-caches
Cache-ControlRi�cCs�d|_t|_||_t�|_t�|_||_	|j
j�}|s�|jdd�}|jd�}|r�d||f}q�n|jj
|jdi��||jd<|jdd�|_dS(	NRbs	text/htmlR&s%s; charset=%sR,sContent-TypeR'R+(Rt_itertTruet_is_str_itertcontentR	R,RROtstatus_codeRR-R.RNR'(RRftmimetypetcodeRR&((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyR,s				
cCsq|jr!dj|j��}nt|j�}djg|jj�D]\}}d||f^qF�d|S(s�Returns a rendition of the full HTTP message, including headers.

        When the content is an iterator, the actual content is replaced with the
        output of str(iterator) (to avoid exhausting the iterator).
        Rs
s%s: %ss

(Retjointget_contenttstrRfR,theaderitems(RRfRtvalue((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt__str__?s	cs�t�j}d�j|f}�jj�}x6�jj�D]%}|jd|jdd�f�q?W|||�t�j	t
�}d|kr�|r�|d�j	�S|r�t�fd�d�S�j�S(s�Convenience call to return output and set status information
        
        Conforms to the WSGI interface for calling purposes only.
        
        Example usage:
        
        .. code-block:: python

            def wsgi_app(environ, start_response):
                response = WSGIResponse()
                response.write("Hello world")
                response.headers['Content-Type'] = 'latin1'
                return response(environ, start_response)
        
        s%s %ss
Set-CookietheaderRswsgi.file_wrappercs
�jj�S(N(Rftread((R(sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt<lambda>gs(
tSTATUS_CODE_TEXTRgR,RmROtvaluesR@toutputt
isinstanceRftfiletiterRk(RR tstart_responsetstatus_texttstatustresponse_headerstctis_file((RsC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt__call__Ms
#
cCs5tj|jjdd��}|r1|jd�SdS(st
        Determine the encoding as specified by the Content-Type's charset
        parameter, if one is set
        sContent-TypeRiN(RPRQR,R.RR(RRS((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytdetermine_charsetjscCs#tjdtd�|jj|�S(s5
        Case-insensitive check for a header
        sOWSGIResponse.has_header is deprecated, use WSGIResponse.headers.has_key insteadi(RRRR,thas_key(RRp((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt
has_headerss	t/c	Cs�||j|<x�d|fd|fd|fd|fd|fd|fgD]D\}	}
|
d	k	rJ|
tk	rJ|
|j||	jdd�<qJqJWd	S(
sJ
        Define a cookie to be sent via the outgoing HTTP headers
        tmax_agetpathtdomaintsecuretexpiresthttponlyt_t-N(RORR0R((RRRnR�R�R�R�R�R�tvar_namet	var_value((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt
set_cookie|s
+cCssd|j|<|dk	r-||j|d<n|dk	rM||j|d<nd|j|d<d|j|d<dS(s�
        Notify the browser the specified cookie has expired and should be
        deleted (via the outgoing HTTP headers)
        RR�R�iR�smax-ageN(ROR(RRR�R�((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt
delete_cookie�s
cCsXt|d�r?||_t|t�r3t|_qTt|_n|g|_t|_dS(Nt__iter__(thasattrRcRvtlistRdReR0(RRf((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt_set_content�s	cCs|jS(N(Rc(R((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyRr�sR7s�Get/set the specified content, where content can be: a string, a list of strings, a generator function that yields strings, or an iterable object that produces strings.cCs3|j�}|r(t|j||j�S|jSdS(s�
        Returns the content as an iterable of strings, encoding each element of
        the iterator from a Unicode object if necessary.
        N(R�R
RfR'(RR&((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyRk�scCs{t|j}d|j|f}|jj�}x6|jj�D]%}|jd|jdd�f�q?W|||j�fS(s|
        Return this WSGIResponse as a tuple of WSGI formatted data, including:
        (status, headers, iterable)
        s%s %ss
Set-CookieRpR(	RsRgR,RmRORtR@RuRk(RRzR{R|R}((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt
wsgi_response�s
#cCs3|jstd|jj�n|jj|�dS(NsDThis %s instance's content is not writable: (content is an iterator)(RetIOErrorRWRRfR@(RRf((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytwrite�s	cCsdS(N((R((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytflush�scCsE|jstd|jj�ntg|jD]}t|�^q,�S(NsCThis %s instance cannot tell its position: (content is an iterator)(ReR�RWRtsumRctlen(Rtchunk((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyttell�s	cCsB|jjd�}|sdStj|�}|r>|jd�SdS(s;
        Get/set the charset (in the Content-Type)
        scontent-typeiN(R,R.RRPRQRR(RRptmatch((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytcharset__get�s
cCs�|dkr|`dSy|jjd�}Wntk
rKtd��nXtj|�}|r�||j� ||j	�}n|d|7}||jd<dS(Nscontent-types:You cannot set the charset when no content-type is defineds; charset=%s(
RR&R,tpoptKeyErrortAttributeErrorRPRQtstarttend(RR&RpR�((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytcharset__set�s

!cCsry|jjd�}Wntk
r*dSXtj|�}|ra||j� ||j�}n||jd<dS(Nscontent-type(R,R�R�RPRQR�R�(RRpR�((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytcharset__del�s
!cCs0|jjd�}|sdS|jdd�dS(s
        Get/set the Content-Type header (or None), *without* the
        charset or any parameters.

        If you include parameters (or ``;`` at all) when setting the
        content_type, any existing parameters will be deleted;
        otherwise they will be preserved.
        scontent-typet;iiN(R,R.Rtsplit(RRp((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytcontent_type__get�s	cCshd|krW|jjdd�}d|krW|jdd�d}|d|7}qWn||jd<dS(NR�scontent-typeRi(R,R.R�(RRnRpRI((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytcontent_type__setscCs&y|jd=Wntk
r!nXdS(Nscontent-type(R,R�(R((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pytcontent_type__dels
N(RRR%RR_RRRRoRR�R�R�R�R�RaRfRkR�R�R�R�R�R�R�R&R�R�R�Rb(((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyR s:						
	
														tCONTINUEidsSWITCHING PROTOCOLSietOKi�tCREATEDi�tACCEPTEDi�sNON-AUTHORITATIVE INFORMATIONi�s
NO CONTENTi�s
RESET CONTENTi�sPARTIAL CONTENTi�sIM USEDi�sMULTIPLE CHOICESi,sMOVED PERMANENTLYi-tFOUNDi.s	SEE OTHERi/sNOT MODIFIEDi0s	USE PROXYi1tRESERVEDi2sTEMPORARY REDIRECTi3sBAD REQUESTi�tUNAUTHORIZEDi�sPAYMENT REQUIREDi�t	FORBIDDENi�s	NOT FOUNDi�sMETHOD NOT ALLOWEDi�sNOT ACCEPTABLEi�sPROXY AUTHENTICATION REQUIREDi�sREQUEST TIMEOUTi�tCONFLICTi�tGONEi�sLENGTH REQUIREDi�sPRECONDITION FAILEDi�sREQUEST ENTITY TOO LARGEi�sREQUEST-URI TOO LONGi�sUNSUPPORTED MEDIA TYPEi�sREQUESTED RANGE NOT SATISFIABLEi�sEXPECTATION FAILEDi�sINTERNAL SERVER ERRORi�sNOT IMPLEMENTEDi�sBAD GATEWAYi�sSERVICE UNAVAILABLEi�sGATEWAY TIMEOUTi�sHTTP VERSION NOT SUPPORTEDi�(%R%treRtpprintRtCookieRt
paste.requestRRRRtpaste.util.multidictRRtpaste.registryRtpaste.responseR	t
paste.wsgilibR
tpaste.httpheadersRtpaste.util.mimeparseRt__all__tcompiletIRPRR_tsettingstobjectRR
RRs(((sC/opt/alt/python27/lib/python2.7/site-packages/paste/wsgiwrappers.pyt<module>sz"	��

Zerion Mini Shell 1.0