ó
TR¹Nc           @   sJ   d  d l  m Z d  d l m Z d  d l m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   BaseStorage(   t   CookieStorage(   t   SessionStoraget   FallbackStoragec           B   s5   e  Z d  Z e e f Z d „  Z d „  Z d „  Z RS(   s   
    Tries to store all messages in the first backend, storing any unstored
    messages in each subsequent backend backend.
    c         O   sQ   t  t |  ƒ j | | Ž  g  |  j D] } | | | Ž  ^ q# |  _ t ƒ  |  _ d  S(   N(   t   superR   t   __init__t   storage_classest   storagest   sett   _used_storages(   t   selft   argst   kwargst   storage_class(    (    sU   /home/panlixing/Python_Projects/gaeseries/django/contrib/messages/storage/fallback.pyR      s    %c         O   sv   g  } xc |  j  D]X } | j ƒ  \ } } | d k r8 Pn  | rQ |  j j | ƒ n  | j | ƒ | r Pq q W| | f S(   sK   
        Gets a single list of messages from all storage backends.
        N(   R   t   _gett   NoneR	   t   addt   extend(   R
   R   R   t   all_messagest   storaget   messagest   all_retrieved(    (    sU   /home/panlixing/Python_Projects/gaeseries/django/contrib/messages/storage/fallback.pyR      s    c         O   sk   xd |  j  D]Y } | r1 | j | | d t ƒ} q
 | |  j k r
 | j g  | ƒ |  j j | ƒ q
 q
 W| S(   sÏ   
        Stores the messages, returning any unstored messages after trying all
        backends.

        For each storage backend, any messages not stored are passed on to the
        next backend.
        t   remove_oldest(   R   t   _storet   FalseR	   t   remove(   R
   R   t   responseR   R   R   (    (    sU   /home/panlixing/Python_Projects/gaeseries/django/contrib/messages/storage/fallback.pyR   %   s    (	   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   (    (    (    sU   /home/panlixing/Python_Projects/gaeseries/django/contrib/messages/storage/fallback.pyR      s
   		N(   t$   django.contrib.messages.storage.baseR    t&   django.contrib.messages.storage.cookieR   t'   django.contrib.messages.storage.sessionR   R   (    (    (    sU   /home/panlixing/Python_Projects/gaeseries/django/contrib/messages/storage/fallback.pyt   <module>   s   