File: //opt/alt/python27/lib/python2.7/site-packages/paste/fileapp.pyc
�
a�Nc           @   s�   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Td d l Td Z d Z	 d d d d	 g Z
 d e f d
 �  �  YZ d e f d �  �  YZ
 d e f d
 �  �  YZ d e f d �  �  YZ d	 e f d �  �  YZ d S(   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   *i   i   t   DataAppt   FileAppt   DirectoryAppt   ArchiveStorec           B   s\   e  Z d  Z d
 Z d d d � Z d �  Z d d � Z d �  Z d �  Z	 d �  Z
 d	 �  Z RS(   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.
    t   GETt   HEADc         K   s   t  | t d  � t f � s! t � d  |  _ d  |  _ d  |  _ d |  _ | d  k	 r] | |  _	 n  | pf g  |  _
 x9 | j �  D]+ \ } } t | � } | j
 |  j
 | � qy Wt j
 |  j
 d t �t |  j
 � s� t j
 |  j
 � n  | d  k	 r� |  j | � n  d  S(   Ni    t   bytes(   t
   isinstancet   typet   Nonet   listt   AssertionErrort   expirest   contentt   content_lengtht
   last_modifiedt   allowed_methodst   headerst   itemst
   get_headert   updatet
   ACCEPT_RANGESt   Truet   CONTENT_TYPEt   set_content(   t   selfR   R   R   t   kwargst   kt   vt   header(    (    s>