o
    þÞh®	  ã                   @   sR   d dl Z d dlmZ d dlmZ d dlmZ eƒ ZG dd„ dƒZ	G dd„ dƒZ
dS )	é    N)Úchecks)ÚRemovedInDjango60Warning)Úcached_propertyc                   @   sH   e Zd ZdZdd„ Zedd„ ƒZefdd„Zdd	„ Z	d
d„ Z
dd„ ZdS )ÚFieldCacheMixinu®   
    An API for working with the model's fields value cache.

    Subclasses must set self.cache_name to a unique entry for the cache -
    typically the fieldâ€™s name.
    c                 C   s   t ‚©N)ÚNotImplementedError©Úself© r
   ú^/var/www/html/premium_crap/venv/lib/python3.10/site-packages/django/db/models/fields/mixins.pyÚget_cache_name   s   zFieldCacheMixin.get_cache_namec                 C   s(   |   ¡ }tjd| jj› d�tdd� |S )Nz	Override z(.cache_name instead of get_cache_name().é   )Ú
stacklevel)r   ÚwarningsÚwarnÚ	__class__Ú__qualname__r   )r	   Ú
cache_namer
   r
   r   r      s   üzFieldCacheMixin.cache_namec                 C   s2   z|j j| j W S  ty   |tu r‚ | Y S w r   )Ú_stateÚfields_cacher   ÚKeyErrorÚNOT_PROVIDED)r	   ÚinstanceÚdefaultr
   r
   r   Úget_cached_value#   s   ýz FieldCacheMixin.get_cached_valuec                 C   s   | j |jjv S r   )r   r   r   ©r	   r   r
   r
   r   Ú	is_cached+   s   zFieldCacheMixin.is_cachedc                 C   s   ||j j| j< d S r   ©r   r   r   )r	   r   Úvaluer
   r
   r   Úset_cached_value.   s   z FieldCacheMixin.set_cached_valuec                 C   s   |j j| j= d S r   r   r   r
   r
   r   Údelete_cached_value1   s   z#FieldCacheMixin.delete_cached_valueN)Ú__name__Ú
__module__r   Ú__doc__r   r   r   r   r   r   r   r    r
   r
   r
   r   r   
   s    
r   c                       s(   e Zd ZdZdd„ Z‡ fdd„Z‡  ZS )ÚCheckFieldDefaultMixin)z<valid default>z<invalid default>c                 C   sD   |   ¡ r | jd ur t| jƒs tjd| jjf d| j | dd�gS g S )Nzk%s default should be a callable instead of an instance so that it's not shared between all field instances.z7Use a callable instead, e.g., use `%s` instead of `%s`.zfields.E010)ÚhintÚobjÚid)Úhas_defaultr   Úcallabler   ÚWarningr   r!   Ú_default_hintr   r
   r
   r   Ú_check_default8   s"   ÿ
ÿþÿ÷ÿz%CheckFieldDefaultMixin._check_defaultc                    s$   t ƒ jdi |¤Ž}| |  ¡ ¡ |S )Nr
   )ÚsuperÚcheckÚextendr,   )r	   ÚkwargsÚerrors©r   r
   r   r.   N   s   zCheckFieldDefaultMixin.check)r!   r"   r   r+   r,   r.   Ú__classcell__r
   r
   r2   r   r$   5   s    r$   )r   Údjango.corer   Údjango.utils.deprecationr   Údjango.utils.functionalr   Úobjectr   r   r$   r
   r
   r
   r   Ú<module>   s    +