Ñò
týMc           @   sV   d  d k  l Z d  d k l Z l Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t
   connection(   t   Usert
   Permissiont   ModelBackendc           B   s\   e  Z d  Z e Z e Z e Z d d d „ Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z RS(   s@   
    Authenticates against django.contrib.auth.models.User.
    c         C   sL   y. t  i i d | ƒ } | i | ƒ o | SWn t  i j
 o d  SXd  S(   Nt   username(   R   t   objectst   gett   check_passwordt   DoesNotExistt   None(   t   selfR   t   passwordt   user(    (    sF   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/backends.pyt   authenticate   s    	c         C   sŸ   t  | d ƒ pˆ | i o t i i ƒ  } n t i i d | ƒ } | i d d ƒ i ƒ  } t g  } | D] \ } } | d | | f qh ~ ƒ | _	 n | i	 S(   sh   
        Returns a set of permission strings that this user has through his/her
        groups.
        t   _group_perm_cachet   group__usert   content_type__app_labelt   codenames   %s.%s(
   t   hasattrt   is_superuserR   R   t   allt   filtert   values_listt   order_byt   setR   (   R
   t   user_objt   permst   _[1]t   ctt   name(    (    sF   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/backends.pyt   get_group_permissions   s    
>c         C   s   | i  ƒ  o t ƒ  St | d ƒ pc t g  } | i i ƒ  D]  } | d | i i | i f q< ~ ƒ | _ | i i	 |  i
 | ƒ ƒ n | i S(   Nt   _perm_cacheu   %s.%s(   t   is_anonymousR   R   t   user_permissionst   select_relatedt   content_typet	   app_labelR   R   t   updateR   (   R
   R   R   t   p(    (    sF   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/backends.pyt   get_all_permissions%   s    Fc         C   s"   | i  p t S| |  i | ƒ j S(   N(   t	   is_activet   FalseR'   (   R
   R   t   perm(    (    sF   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/backends.pyt   has_perm-   s    
c         C   sL   | i  p t Sx6 |  i | ƒ D]% } | | i d ƒ  | j o t Sq Wt S(   sV   
        Returns True if user_obj has any permissions in the given app_label.
        t   .(   R(   R)   R'   t   indext   True(   R
   R   R$   R*   (    (    sF   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/backends.pyt   has_module_perms2   s    
 	c         C   s5   y t  i i d | ƒ SWn t  i j
 o d  SXd  S(   Nt   pk(   R   R   R   R   R	   (   R
   t   user_id(    (    sF   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/backends.pyt   get_user=   s    N(   t   __name__t
   __module__t   __doc__R)   t   supports_object_permissionsR.   t   supports_anonymous_usert   supports_inactive_userR	   R   R   R'   R+   R/   R2   (    (    (    sF   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/backends.pyR      s   				t   RemoteUserBackendc           B   s/   e  Z d  Z e Z d „  Z d „  Z d „  Z RS(   sÆ  
    This backend is to be used in conjunction with the ``RemoteUserMiddleware``
    found in the middleware module of this package, and is used when the server
    is handling authentication outside of Django.

    By default, the ``authenticate`` method creates ``User`` objects for
    usernames that don't already exist in the database.  Subclasses can disable
    this behavior by setting the ``create_unknown_user`` attribute to
    ``False``.
    c         C   sš   | p d Sd } |  i | ƒ } |  i o9 t i i d | ƒ \ } } | o |  i | ƒ } q– n3 y t i i d | ƒ } Wn t i j
 o n X| S(   s  
        The username passed as ``remote_user`` is considered trusted.  This
        method simply returns the ``User`` object with the given username,
        creating a new ``User`` object if ``create_unknown_user`` is ``True``.

        Returns None if ``create_unknown_user`` is ``False`` and a ``User``
        object with the given username is not found in the database.
        NR   (	   R	   t   clean_usernamet   create_unknown_userR   R   t   get_or_createt   configure_userR   R   (   R
   t   remote_userR   R   t   created(    (    sF   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/backends.pyR   S   s    	
c         C   s   | S(   sÉ   
        Performs any cleaning on the "username" prior to using it to get or
        create the user object.  Returns the cleaned username.

        By default, returns the username unchanged.
        (    (   R
   R   (    (    sF   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/backends.pyR:   o   s    c         C   s   | S(   s‚   
        Configures a user after creation and returns the updated user.

        By default, returns the user unmodified.
        (    (   R
   R   (    (    sF   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/backends.pyR=   x   s    (   R3   R4   R5   R.   R;   R   R:   R=   (    (    (    sF   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/backends.pyR9   D   s
   
			N(   t	   django.dbR    t   django.contrib.auth.modelsR   R   t   objectR   R9   (    (    (    sF   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/backends.pyt   <module>   s   ?