3
(h!              
   @   s   d dl mZ d dlmZ d dlmZ dZG dd deZdddZ	dd Z
dd Zdd ZdddZddd	Zddd
Zd ddZd!ddZdS )"    )	constants)default_storage)HttpRequestadd_messageget_messages	get_level	set_leveldebuginfosuccesswarningerrorMessageFailurec               @   s   e Zd ZdS )r   N)__name__
__module____qualname__ r   r   ?/tmp/pip-install-q3hcpn_q/Django/django/contrib/messages/api.pyr      s    Fc             C   sD   t | tstd| jj t| dr4| jj|||S |s@tddS )zL
    Attempts to add a message to the request using the 'messages' app.
    z?add_message() argument must be an HttpRequest object, not '%s'.	_messagesz_You cannot add messages without installing django.contrib.messages.middleware.MessageMiddlewareN)	
isinstancer   	TypeError	__class__r   hasattrr   addr   )requestlevelmessage
extra_tagsfail_silentlyr   r   r   r      s    

c             C   s   t | dg S )zg
    Returns the message storage on the request if it exists, otherwise returns
    an empty list.
    r   )getattr)r   r   r   r   r   !   s    c             C   s   t | dt| }|jS )z
    Returns the minimum level of messages to be recorded.

    The default level is the ``MESSAGE_LEVEL`` setting. If this is not found,
    the ``INFO`` level is used.
    r   )r    r   r   )r   Zstorager   r   r   r   )   s    c             C   s   t | dsdS || j_dS )z
    Sets the minimum level of messages to be recorded, returning ``True`` if
    the level was recorded successfully.

    If set to ``None``, the default level will be used (see the ``get_level``
    method).
    r   FT)r   r   r   )r   r   r   r   r   r   4   s    
c             C   s   t | tj|||d dS )z2
    Adds a message with the ``DEBUG`` level.
    )r   r   N)r   r   DEBUG)r   r   r   r   r   r   r   r	   B   s    c             C   s   t | tj|||d dS )z1
    Adds a message with the ``INFO`` level.
    )r   r   N)r   r   INFO)r   r   r   r   r   r   r   r
   J   s    c             C   s   t | tj|||d dS )z4
    Adds a message with the ``SUCCESS`` level.
    )r   r   N)r   r   SUCCESS)r   r   r   r   r   r   r   r   R   s    c             C   s   t | tj|||d dS )z4
    Adds a message with the ``WARNING`` level.
    )r   r   N)r   r   WARNING)r   r   r   r   r   r   r   r   Z   s    c             C   s   t | tj|||d dS )z2
    Adds a message with the ``ERROR`` level.
    )r   r   N)r   r   ERROR)r   r   r   r   r   r   r   r   b   s    N)
r   r   r   r   r	   r
   r   r   r   r   )r   F)r   F)r   F)r   F)r   F)r   F)Zdjango.contrib.messagesr   Zdjango.contrib.messages.storager   Zdjango.httpr   __all__	Exceptionr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   <module>   s       




