Ë
    £2Úi¯  ã                   ó€   — d dl mZ d dlmZ d dlmZ ddlmZ  eedd«      Z	 G d„ d	e«      Z
 G d
„ de
«      Zd„ Zd„ Zy)é    )Úsettings)Úget_object_or_404)Ú
LazyObjecté   )Úreverse_hostÚHOST_SITE_TIMEOUTi  c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLazySitec                 ó�   •— t         t        | �  «        | j                  j	                  |j
                  j                  ||dœ«       y )N)ÚnameÚargsÚkwargs)Úsuperr
   Ú__init__Ú__dict__ÚupdateÚhostr   )ÚselfÚrequestr   r   Ú	__class__s       €úM/var/www/html/acx/venv/lib/python3.12/site-packages/django_hosts/callbacks.pyr   zLazySite.__init__   s:   ø€ ÜŒh˜Ñ&Ô(Ø�‰×ÑØ—L‘L×%Ñ%ØØñ
õ 	ó    c                 ó�   — t        | j                  | j                  | j                  ¬«      }ddlm} t        ||¬«      }|| _        y )N©r   r   r   ©ÚSite©Údomain__iexact)r   r   r   r   Údjango.contrib.sites.modelsr   r   Ú_wrapped)r   r   r   Úsites       r   Ú_setupzLazySite._setup   s2   € Ü˜DŸI™I¨D¯I©I¸d¿k¹kÔJˆÝ4Ü  °dÔ;ˆØˆ�r   )Ú__name__Ú
__module__Ú__qualname__r   r"   Ú__classcell__)r   s   @r   r
   r
   
   s   ø„ ôör   r
   c                   ó   — e Zd Zd„ Zy)ÚCachedLazySitec                 ó  — t        | j                  | j                  | j                  ¬«      }d|z  }ddlm} |j                  |d «      }|�|| _        y ddlm	} t        ||¬«      }|j                  ||t        «       || _        y )Nr   zhosts:%sr   )Úcacher   r   )r   r   r   r   Údjango.core.cacher*   Úgetr    r   r   r   Úsetr   )r   r   Ú	cache_keyr*   r!   r   s         r   r"   zCachedLazySite._setup   sp   € Ü˜DŸI™I¨D¯I©I¸d¿k¹kÔJˆØ Ñ%ˆ	Ý+Ø�y‰y˜ DÓ)ˆØÐØ ˆDŒMØÝ4Ü  °dÔ;ˆØ�	‰	�)˜TÔ#4Ô5Øˆ�r   N)r#   r$   r%   r"   © r   r   r(   r(      s   „ ór   r(   c                 ó,   — t        | g|¢­i |¤Ž| _        y)aó  
    A callback function which uses the :mod:`django.contrib.sites` contrib
    app included in Django to match a host to a
    :class:`~django.contrib.sites.models.Site` instance, setting a
    ``request.site`` attribute on success.

    :param request: the request object passed from the middleware
    :param \*args: the parameters as matched by the host patterns
    :param \*\*kwargs: the keyed parameters as matched by the host patterns

    It's important to note that this uses
    :func:`~django_hosts.resolvers.reverse_host` behind the scenes to
    reverse the host with the given arguments and keyed arguments to
    enable a flexible configuration of what will be used to retrieve
    the :class:`~django.contrib.sites.models.Site` instance -- in the end
    the callback will use a ``domain__iexact`` lookup to get it.

    For example, imagine a host conf with a username parameter::

        from django.conf import settings
        from django_hosts import patterns, host

        settings.PARENT_HOST = 'example.com'

        host_patterns = patterns('',
            host(r'www', settings.ROOT_URLCONF, name='www'),
            host(r'(?P<username>\w+)', 'path.to.custom_urls',
                 callback='django_hosts.callbacks.host_site',
                 name='user-sites'),
        )

    When requesting this website with the host ``jezdez.example.com``,
    the callback will act as if you'd do::

        request.site = Site.objects.get(domain__iexact='jezdez.example.com')

    ..since the result of calling :func:`~django_hosts.resolvers.reverse_host`
    with the username ``'jezdez'`` is ``'jezdez.example.com'``.

    Later, in your views, you can nicely refer to the current site
    as ``request.site`` for further site-specific functionality.
    N)r
   r!   ©r   r   r   s      r   Ú	host_siter2   +   s   € ôV ˜GÐ5 dÒ5¨fÑ5€G…Lr   c                 ó,   — t        | g|¢­i |¤Ž| _        y)aç  
    A callback function similar to :func:`~django_hosts.callbacks.host_site`
    which caches the resulting :class:`~django.contrib.sites.models.Site`
    instance in the default cache backend for the time specfified as
    :attr:`~django.conf.settings.HOST_SITE_TIMEOUT`.

    :param request: the request object passed from the middleware
    :param \*args: the parameters as matched by the host patterns
    :param \*\*kwargs: the keyed parameters as matched by the host patterns
    N)r(   r!   r1   s      r   Úcached_host_siter4   Y   s   € ô " 'Ð;¨DÒ;°FÑ;€G…Lr   N)Údjango.confr   Údjango.shortcutsr   Údjango.utils.functionalr   Ú	resolversr   Úgetattrr   r
   r(   r2   r4   r/   r   r   ú<module>r:      sD   ðÝ  Ý .Ý .å #á˜HÐ&9¸4Ó@Ð ôˆzô ô"�Xô ò +6ó\<r   