ó
ø¢TQc           @   s—   d  d l  m Z d  d l m Z d  d l m Z i  a d e j f d „  ƒ  YZ	 e d e j
 f d „  ƒ  Yƒ Z e d e f d	 „  ƒ  Yƒ Z d
 „  Z d S(   iÿÿÿÿ(   t   models(   t   ugettext_lazy(   t   python_2_unicode_compatiblet   SiteManagerc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   d d l  m } y | j } Wn- t k
 rL d d l m } | d ƒ ‚ n Xy t | } Wn- t k
 rŠ |  j d | ƒ } | t | <n X| S(   s½   
        Returns the current ``Site`` based on the SITE_ID in the
        project's settings. The ``Site`` object is cached the first
        time it's retrieved from the database.
        iÿÿÿÿ(   t   settings(   t   ImproperlyConfiguredsŸ   You're using the Django "sites framework" without having set the SITE_ID setting. Create a site in your database and set the SITE_ID setting to fix this error.t   pk(	   t   django.confR   t   SITE_IDt   AttributeErrort   django.core.exceptionsR   t
   SITE_CACHEt   KeyErrort   get(   t   selfR   t   sidR   t   current_site(    (    s4   ../Django//lib/python/django/contrib/sites/models.pyt   get_current   s    c         C   s
   i  a  d S(   s!   Clears the ``Site`` object cache.N(   R   (   R   (    (    s4   ../Django//lib/python/django/contrib/sites/models.pyt   clear_cache   s    (   t   __name__t
   __module__R   R   (    (    (    s4   ../Django//lib/python/django/contrib/sites/models.pyR   	   s   	t   Sitec           B   su   e  Z e j e d  ƒ d d ƒZ e j e d ƒ d d ƒZ e ƒ  Z d d
 d „  ƒ  YZ	 d „  Z
 d „  Z d	 „  Z RS(   s   domain namet
   max_lengthid   s   display namei2   t   Metac           B   s,   e  Z d  Z e d ƒ Z e d ƒ Z d Z RS(   t   django_sitet   sitet   sitest   domain(   s   domain(   R   R   t   db_tablet   _t   verbose_namet   verbose_name_pluralt   ordering(    (    (    s4   ../Django//lib/python/django/contrib/sites/models.pyR   +   s   c         C   s   |  j  S(   N(   R   (   R   (    (    s4   ../Django//lib/python/django/contrib/sites/models.pyt   __str__1   s    c         O   s9   t  t |  ƒ j | | Ž  |  j t k r5 t |  j =n  d  S(   N(   t   superR   t   savet   idR   (   R   t   argst   kwargs(    (    s4   ../Django//lib/python/django/contrib/sites/models.pyR#   4   s    c         C   s?   |  j  } t t |  ƒ j ƒ  y t | =Wn t k
 r: n Xd  S(   N(   R   R"   R   t   deleteR   R   (   R   R   (    (    s4   ../Django//lib/python/django/contrib/sites/models.pyR'   :   s    	(    (   R   R   R    t	   CharFieldR   R   t   nameR   t   objectsR   R!   R#   R'   (    (    (    s4   ../Django//lib/python/django/contrib/sites/models.pyR   $   s   			t   RequestSitec           B   s8   e  Z d  Z d „  Z d „  Z e e d „ Z d „  Z RS(   s  
    A class that shares the primary interface of Site (i.e., it has
    ``domain`` and ``name`` attributes) but gets its data from a Django
    HttpRequest object rather than from a database.

    The save() and delete() methods raise NotImplementedError.
    c         C   s   | j  ƒ  |  _ |  _ d  S(   N(   t   get_hostR   R)   (   R   t   request(    (    s4   ../Django//lib/python/django/contrib/sites/models.pyt   __init__L   s    c         C   s   |  j  S(   N(   R   (   R   (    (    s4   ../Django//lib/python/django/contrib/sites/models.pyR!   O   s    c         C   s   t  d ƒ ‚ d  S(   Ns   RequestSite cannot be saved.(   t   NotImplementedError(   R   t   force_insertt   force_update(    (    s4   ../Django//lib/python/django/contrib/sites/models.pyR#   R   s    c         C   s   t  d ƒ ‚ d  S(   Ns   RequestSite cannot be deleted.(   R/   (   R   (    (    s4   ../Django//lib/python/django/contrib/sites/models.pyR'   U   s    (   R   R   t   __doc__R.   R!   t   FalseR#   R'   (    (    (    s4   ../Django//lib/python/django/contrib/sites/models.pyR+   C   s
   		c         C   s.   t  j j r t  j j ƒ  } n t |  ƒ } | S(   s“   
    Checks if contrib.sites is installed and returns either the current
    ``Site`` object or a ``RequestSite`` object based on the request.
    (   R   t   _metat	   installedR*   R   R+   (   R-   R   (    (    s4   ../Django//lib/python/django/contrib/sites/models.pyt   get_current_siteY   s    N(   t	   django.dbR    t   django.utils.translationR   R   t   django.utils.encodingR   R   t   ManagerR   t   ModelR   t   objectR+   R6   (    (    (    s4   ../Django//lib/python/django/contrib/sites/models.pyt   <module>   s   