%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/fileapp.pyc

�
a�Nc@s�dZddlZddlZddlZddlZddlZddlTddlTdZdZ	dddd	gZ
defd
��YZdefd��YZ
defd
��YZdefd��YZd	efd��YZdS(s�
This module handles sending static content such as in-memory data or
files.  At this time it has cache helpers and understands the
if-modified-since request header.
i����N(t*iitDataApptFileApptDirectoryApptArchiveStorecBs\eZdZd
Zddd�Zd�Zdd�Zd�Zd�Z	d�Z
d	�ZRS(s�
    Returns an application that will send content in a single chunk,
    this application has support for setting cache-control and for
    responding to conditional (or HEAD) requests.

    Constructor Arguments:

        ``content``     the content being sent to the client

        ``headers``     the headers to send /w the response

        The remaining ``kwargs`` correspond to headers, where the
        underscore is replaced with a dash.  These values are only
        added to the headers if they are not already provided; thus,
        they can be used for default values.  Examples include, but
        are not limited to:

            ``content_type``
            ``content_encoding``
            ``content_location``

    ``cache_control()``

        This method provides validated construction of the ``Cache-Control``
        header as well as providing for automated filling out of the
        ``EXPIRES`` header for HTTP/1.0 clients.

    ``set_content()``

        This method provides a mechanism to set the content after the
        application has been constructed.  This method does things
        like changing ``Last-Modified`` and ``Content-Length`` headers.

    tGETtHEADcKst|td�tf�s!t�d|_d|_d|_d|_|dk	r]||_	n|pfg|_
x9|j�D]+\}}t|�}|j
|j
|�qyWtj
|j
dt�t|j
�s�tj
|j
�n|dk	r�|j|�ndS(Nitbytes(t
isinstancettypetNonetlisttAssertionErrortexpirestcontenttcontent_lengtht
last_modifiedtallowed_methodstheaderstitemst
get_headertupdatet
ACCEPT_RANGEStTruetCONTENT_TYPEtset_content(tselfRRRtkwargstktvtheader((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyt__init__;s !				cKs"tj|j|�pd|_|S(N(t
CACHE_CONTROLtapplyRR
R
(RR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyt
cache_controlNscCsn|dk	st�|dkr0tj�|_n	||_||_t|�|_tj|j	d|j�|S(Nttime(
R
RR#RRtlenRt
LAST_MODIFIEDRR(RRR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyRRs		cKstj|j|�|S(N(tCONTENT_DISPOSITIONR!R(RR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pytcontent_disposition]scCsg|dj�}||jkrWtd|dddj|j�fg�}|||�S|j||�S(NtREQUEST_METHODsYou cannot %s a fileRtAllowt,(tupperRtHTTPMethodNotAllowedtjointget(Rtenvirontstart_responsetmethodtexc((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyt__call__as

cCsd|j|jfS(Ns"%s-%s"(RR(R((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pytcalculate_etagjscCs�|j}|j�}tj||�|jdk	rNtj|d|j�ny�tj|�}|r�xd|D]Y}||ks�|dkrmx$t	dt
�D]}|j|�q�W|d|�dgSqmWnWn tk
r�}|j
||�SX|s�yctj|�}	|	t|j�krYx$t	dt
�D]}|j|�q.W|d|�dgSWq�tk
r|}|j
||�SXnd|jd}
}tj|�}|r=d|dkr=dt|d�kr=|dd\}
}|p�|jd}||jks|
|kr=td	|jt|�f�j
||�Sn||
d}
tj|d
|
d|d|j�tj||
�|
|jkr�|d
|�n
|d|�|jdk	r�|j|
|d!gS|
|
fS(NtdeltaRtentitys304 Not ModifiedtiiRsWRange request was made beyond the end of the content,
which is %s long.
  Range: %s
t
first_bytet	last_bytettotal_lengths200 OKs206 Partial Content(RR4tETAGRR
R
tEXPIRESt
IF_NONE_MATCHtparsetlist_headersRtdeletetHTTPBadRequesttwsgi_applicationtIF_MODIFIED_SINCEtintRRtRANGER$tHTTPRequestRangeNotSatisfiablet
CONTENT_RANGEtCONTENT_LENGTHR(RR/R0Rtcurrent_etagtclient_etagstetagtheadtexcetclient_clocktlowerR+trangeR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR.ms\



,


(RRN(t__name__t
__module__t__doc__RR
RR"RR'R3R4R.(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyRs"					cBs8eZdZdd�Zd�Zed�Zd�ZRS(s�
    Returns an application that will send the file at the given
    filename.  Adds a mime type based on ``mimetypes.guess_type()``.
    See DataApp for the arguments beyond ``filename``.
    cKss||_|j�\}}|r:d|kr:||d<n|rYd|krY||d<ntj|d||�dS(Ntcontent_typetcontent_encoding(tfilenamet
guess_typeRRR
(RRVRRRTRU((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR�s	

cCstj|j�S(N(t	mimetypesRWRV(R((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyRW�scCs�tj|j�}|r/|j|jkr/dS|j|_|jtkr�t|jd�}|j|j	�|j�|j
�n.d|_|j|_
tj|jd|j�dS(NtrbR#(toststatRVtst_mtimeRtst_sizet
CACHE_SIZEtopenRtreadtcloseR
RRR%RR(RtforceR[tfh((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR�s
	cCsu|dj�dk}dt|�j�krA|jdt�n
|j�|js�tjj|j	�s�t
ddd|j	�}|||�Syt|j	d�}Wq�tt
fk
r�}td	|�}|j||�SXntj|||�}t|t�r|rd
gS|S|\}}	|r/d
gS|j|�|jdd�}
|
ra|
|t�St|d|	�SdS(
NR(Rs	max-age=0RbsThe resource does not existtcomments
No file at %rRYs,You are not permitted to view this file (%s)R7swsgi.file_wrappertsize(R+R RORRRRZtpathtexistsRVtHTTPNotFoundR_tIOErrortOSErrort
HTTPForbiddenRBRR.RRtseekR
t
BLOCK_SIZEt	_FileIter(RR/R0tis_headR2tfiletetretvalRORtfile_wrapper((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR.�s<
	



N(	RQRRRSR
RRWtFalseRR.(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR�s
		RncBs2eZddd�Zd�Zd�Zd�ZRS(cCs%||_||_|pt|_dS(N(RpReRmt
block_size(RRpRuRe((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR�s		cCs|S(N((R((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyt__iter__�scCsj|j}|jdk	rE||jkr3|j}n|j|8_n|jj|�}|sft�n|S(N(RuReR
RpR`t
StopIteration(Rt
chunk_sizetdata((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pytnext�s		cCs|jj�dS(N(RpRa(R((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyRasN(RQRRR
RRvRzRa(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyRn�s		cBs&eZdZd�ZeZd�ZRS(s
    Returns an application that dispatches requests to corresponding FileApps based on PATH_INFO.
    FileApp instances are cached. This app makes sure not to serve any files that are not in a subdirectory.
    To customize FileApp creation override ``DirectoryApp.make_fileapp``
    cCsmtjj|�|_|jjtjj�sE|jtjj7_ntjj|j�s`t�i|_dS(N(RZRftabspathtendswithtseptisdirRtcached_apps(RRf((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyRs
cCs�|d}|jj|�}|dkr�tjj|j|jd��}tjj|�j|j�sst	�}q�tjj
|�r�|j|�}||j|<q�td|�}n|||�S(Nt	PATH_INFOt/Rd(
RR.R
RZRfR-tlstriptnormpatht
startswithRktisfiletmake_fileappRh(RR/R0t	path_infotappRf((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR3s
!(RQRRRSRRR�R3(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyRs	cBs)eZdZd�Zd�Zd�ZRS(s�
    Returns an application that serves up a DataApp for items requested
    in a given zip or tar archive.

    Constructor Arguments:

        ``filepath``    the path to the archive being served

    ``cache_control()``

        This method provides validated construction of the ``Cache-Control``
        header as well as providing for automated filling out of the
        ``EXPIRES`` header for HTTP/1.0 clients.
    cCs�tj|�r'tj|d�|_n7tj|�rNtj|d�|_ntd|��d|_	t
j
�|_i|_dS(Ntrs"filepath '%s' is not a zip or tar (
tzipfilet
is_zipfiletZipFiletarchivettarfilet
is_tarfilet
TarFileCompatRR
R
R#Rtcache(Rtfilepath((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR7s	cKs"tj|j|�pd|_|S(N(R R!RR
R
(RR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR"Bsc
Cso|jdd�}|jd�r.|d}n|jj|�}|rS|||�Sy|jj|�}Wn.tk
r�td|�}|j||�SX|jj	d�r�td|�}|j||�St
j|j�\}}|dk	rt
dd|d|�}	nt
dd|�}	|	j|jj|�tj|jd
��|	|j|<|j|	_|	||�S(NR�R7R�is(The file requested, '%s', was not found.s$Path requested, '%s', is not a file.RTRUi(iii(R.R�R�R�tgetinfotKeyErrorRhRBRVR|RXRWR
RRR`R#tmktimet	date_timeR
(
RR/R0RftapplicationtinfoR2RTRUR�((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR3Fs0



(RQRRRSRR"R3(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR's		i(RSRZR#RXR�R�tpaste.httpexceptionstpaste.httpheadersR^Rmt__all__tobjectRRRnRR(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyt<module>
s<

�F

Zerion Mini Shell 1.0