%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/alt/python27/lib/python2.7/site-packages/paste/
Upload File :
Create Path :
Current File : //proc/self/root/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyo

�
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.

    tGETtHEADcKs�d|_d|_d|_d|_|dk	r<||_n|pEg|_x9|j�D]+\}}t|�}|j	|j|�qXWt
j	|jdt�t|j�s�tj	|j�n|dk	r�|j
|�ndS(Nitbytes(tNonetexpirestcontenttcontent_lengtht
last_modifiedtallowed_methodstheaderstitemst
get_headertupdatet
ACCEPT_RANGEStTruetCONTENT_TYPEtset_content(tselfR
RR
tkwargstktvtheader((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyt__init__;s				cKs"tj|j|�pd|_|S(N(t
CACHE_CONTROLtapplyRRR	(RR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyt
cache_controlNscCs\|dkrtj�|_n	||_||_t|�|_tj|jd|j�|S(Nttime(	RRRR
tlenRt
LAST_MODIFIEDRR(RR
R((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyRRs		cKstj|j|�|S(N(tCONTENT_DISPOSITIONRR(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,(tupperR
tHTTPMethodNotAllowedtjointget(Rtenvirontstart_responsetmethodtexc((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyt__call__as

cCsd|j|jfS(Ns"%s-%s"(RR(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(RR0tETAGRR	RtEXPIRESt
IF_NONE_MATCHtparsetlist_headersRtdeletetHTTPBadRequesttwsgi_applicationtIF_MODIFIED_SINCEtintRRtRANGER tHTTPRequestRangeNotSatisfiablet
CONTENT_RANGEtCONTENT_LENGTHR
(RR+R,Rt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__R
RRRRR#R/R0R*(((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(RRRRRRPRQ((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR�s	

cCstj|j�S(N(t	mimetypesRSRR(R((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyRS�scCs�tj|j�}|r/|j|jkr/dS|j|_|jtkr�t|jd�}|j|j	�|j�|j
�n.d|_|j|_
tj|jd|j�dS(NtrbR(toststatRRtst_mtimeRtst_sizet
CACHE_SIZEtopenRtreadtcloseRR
RR!RR(RtforceRWtfh((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=0R^sThe resource does not existtcomments
No file at %rRUs,You are not permitted to view this file (%s)R3swsgi.file_wrappertsize(R'RRKRRR
RVtpathtexistsRRtHTTPNotFoundR[tIOErrortOSErrort
HTTPForbiddenR>RR*t
isinstancetlisttseekRt
BLOCK_SIZEt	_FileIter(RR+R,tis_headR.tfiletetretvalRKRtfile_wrapper((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR*�s<
	



N(	RMRNRORRRStFalseRR*(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR�s
		RlcBs2eZddd�Zd�Zd�Zd�ZRS(cCs%||_||_|pt|_dS(N(RnRaRkt
block_size(RRnRsRa((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(RsRaRRnR\t
StopIteration(Rt
chunk_sizetdata((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pytnext�s		cCs|jj�dS(N(RnR](R((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR]sN(RMRNRRRtRxR](((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyRl�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``
    cCsRtjj|�|_|jjtjj�sE|jtjj7_ni|_dS(N(RVRbtabspathtendswithtseptcached_apps(RRb((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyRscCs�|d}|jj|�}|dkr�tjj|j|jd��}tjj|�j|j�sst	�}q�tjj
|�r�|j|�}||j|<q�td|�}n|||�S(Nt	PATH_INFOt/R`(
R|R*RRVRbR)tlstriptnormpatht
startswithRgtisfiletmake_fileappRd(RR+R,t	path_infotappRb((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR/s
!(RMRNRORRR�R/(((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
TarFileCompattAssertionErrorRR	RRtcache(Rtfilepath((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR7s	cKs"tj|j|�pd|_|S(N(RRRRR	(RR((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyRBsc
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}R3R~is(The file requested, '%s', was not found.s$Path requested, '%s', is not a file.RPRQi(iii(R*R�R�R�tgetinfotKeyErrorRdR>RRRzRTRSRRRR\Rtmktimet	date_timeR	(
RR+R,RbtapplicationtinfoR.RPRQR�((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR/Fs0



(RMRNRORRR/(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyR's		i(RORVRRTR�R�tpaste.httpexceptionstpaste.httpheadersRZRkt__all__tobjectRRRlRR(((s>/opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyt<module>
s<

�F

Zerion Mini Shell 1.0