
vÅÏ^ÿ  ã            
   @   sÐ   d  d l  m Z d  d l m Z d Z Gd d „  d e ƒ Z d d d d „ Z d d „  Z d d „  Z	 d d „  Z
 d d d d „ Z d d d d „ Z d d d d	 „ Z d d d d
 „ Z d d d d „ Z d S)é    )Ú	constants)Údefault_storageÚ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-build-8lau8j11/django/django/contrib/messages/api.pyr      s   Ú Fc             C   sp   y |  j  } WnI t k
 rX t |  d ƒ sB t d |  j j ƒ ‚ | sT t d ƒ ‚ Yn X| j | | | ƒ Sd S)zK
    Attempt to add a message to the request using the 'messages' app.
    ZMETAz?add_message() argument must be an HttpRequest object, not '%s'.z_You cannot add messages without installing django.contrib.messages.middleware.MessageMiddlewareN)Ú	_messagesÚAttributeErrorÚhasattrÚ	TypeErrorÚ	__class__r   r   Úadd)ÚrequestÚlevelÚmessageÚ
extra_tagsÚfail_silentlyÚmessagesr   r   r   r      s    c             C   s   t  |  d g  ƒ S)ze
    Return the message storage on the request if it exists, otherwise return
    an empty list.
    r   )Úgetattr)r   r   r   r   r   %   s    c             C   s   t  |  d t |  ƒ ƒ } | j S)z©
    Return the minimum level of messages to be recorded.

    The default level is the ``MESSAGE_LEVEL`` setting. If this is not found,
    use the ``INFO`` level.
    r   )r    r   r   )r   Zstorager   r   r   r   -   s    c             C   s#   t  |  d ƒ s d S| |  j _ d S)zÊ
    Set the minimum level of messages to be recorded, and return ``True`` if
    the level was recorded successfully.

    If set to ``None``, use the default level (see the get_level() function).
    r   FT)r   r   r   )r   r   r   r   r   r   8   s    c             C   s#   t  |  t j | d | d | ƒd S)z'Add a message with the ``DEBUG`` level.r   r   N)r   r   ÚDEBUG)r   r   r   r   r   r   r   r   E   s    c             C   s#   t  |  t j | d | d | ƒd S)z&Add a message with the ``INFO`` level.r   r   N)r   r   ÚINFO)r   r   r   r   r   r   r   r	   K   s    c             C   s#   t  |  t j | d | d | ƒd S)z)Add a message with the ``SUCCESS`` level.r   r   N)r   r   ÚSUCCESS)r   r   r   r   r   r   r   r
   Q   s    c             C   s#   t  |  t j | d | d | ƒd S)z)Add a message with the ``WARNING`` level.r   r   N)r   r   ÚWARNING)r   r   r   r   r   r   r   r   W   s    c             C   s#   t  |  t j | d | d | ƒd S)z'Add a message with the ``ERROR`` level.r   r   N)r   r   ÚERROR)r   r   r   r   r   r   r   r   ]   s    N)
zadd_messagezget_messagesz	get_levelz	set_levelzdebugzinfozsuccesszwarningzerrorzMessageFailure)Zdjango.contrib.messagesr   Zdjango.contrib.messages.storager   Ú__all__Ú	Exceptionr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   Ú<module>   s      