
Mc           @   s  d  d k  Z  d  d k Z d  d k l Z d  d k l Z d  d k l Z d  d k l	 Z	 d  d k
 l Z d  d k l Z d  d k l Z d  d	 k l Z l Z d  d
 k l Z d  d k l Z d Z d   Z d   Z d   Z e i e  d e f d     YZ d e	 i f d     YZ  d e	 i! f d     YZ" d e	 i! f d     YZ# d e	 i f d     YZ$ d   Z% d   Z& d   Z' d e	 i! f d     YZ( d e	 i! f d      YZ) d! e* f d"     YZ+ d S(#   iN(   t   auth(   t   user_logged_in(   t   ImproperlyConfigured(   t   models(   t   EmptyManager(   t   ContentType(   t	   smart_str(   t   md5_constructort   sha_constructor(   t   ugettext_lazy(   t   constant_time_comparet   !c         C   s   t  |  t  |  } } |  d j oC y d d k } Wn t j
 o t d   n X| i | |  S|  d j o t | |  i   S|  d j o t | |  i   St d   d S(   s   
    Returns a string of the hexdigest of the given plaintext password and salt
    using the given algorithm ('md5', 'sha1' or 'crypt').
    t   cryptiNs<   "crypt" password algorithm not supported in this environmentt   md5t   sha1s0   Got unknown password algorithm type in password.(   R   R   t   ImportErrort
   ValueErrorR   t	   hexdigestR   (   t	   algorithmt   saltt   raw_passwordR   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   get_hexdigest   s    c         C   s1   | i  d  \ } } } t | t | | |    S(   sv   
    Returns a boolean of whether the raw_password was correct. Handles
    encryption formats behind the scenes.
    t   $(   t   splitR
   R   (   R   t   enc_passwordt   algoR   t   hsh(    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   check_password%   s    c         K   s    t  i  i   | _ | i   d S(   sZ   
    A signal receiver which updates the last_login date for
    the user logging in.
    N(   t   datetimet   nowt
   last_logint   save(   t   sendert   usert   kwargs(    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   update_last_login-   s    t   SiteProfileNotAvailablec           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR$   6   s   t   PermissionManagerc           B   s   e  Z d    Z RS(   c         C   s%   |  i  d | d t i i | |   S(   Nt   codenamet   content_type(   t   getR   t   objectst   get_by_natural_key(   t   selfR(   t	   app_labelt   model(    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR,   :   s    	(   R%   R&   R,   (    (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR'   9   s   t
   Permissionc           B   s   e  Z d  Z e i e d  d d Z e i e  Z	 e i e d  d d Z
 e   Z d d d     YZ d   Z d	   Z d
 g e _ RS(   s  The permissions system provides a way to assign permissions to specific users and groups of users.

    The permission system is used by the Django admin site, but may also be useful in your own code. The Django admin site uses permissions as follows:

        - The "add" permission limits the user's ability to view the "add" form and add an object.
        - The "change" permission limits a user's ability to view the change list, view the "change" form and change an object.
        - The "delete" permission limits the ability to delete an object.

    Permissions are set globally per type of object, not per specific object instance. It is possible to say "Mary may change news stories," but it's not currently possible to say "Mary may change news stories, but only the ones she created herself" or "Mary may only change news stories that have a certain status or publication date."

    Three basic permissions -- add, change and delete -- are automatically created for each Django model.
    t   namet
   max_lengthi2   R(   id   t   Metac           B   s,   e  Z e d   Z e d  Z d Z d Z RS(	   t
   permissiont   permissionsR)   R(   t   content_type__app_labelt   content_type__model(   s   content_types   codename(   (   s   content_types   codename(   R6   R7   s   codename(   R%   R&   t   _t   verbose_namet   verbose_name_pluralt   unique_togethert   ordering(    (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR3   R   s   c         C   s/   d t  |  i i  t  |  i  t  |  i  f S(   Nu   %s | %s | %s(   t   unicodeR)   R.   R1   (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   __unicode__X   s    c         C   s   |  i  f |  i i   S(   N(   R(   R)   t   natural_key(   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR?   ^   s    s   contenttypes.contenttype(    (   R%   R&   t   __doc__R   t	   CharFieldR8   R1   t
   ForeignKeyR   R)   R(   R'   R+   R3   R>   R?   t   dependencies(    (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR0   @   s   			t   Groupc           B   sl   e  Z d  Z e i e d  d d d e Z e i e	 d e d  d e Z
 d d d	     YZ d
   Z RS(   s  Groups are a generic way of categorizing users to apply permissions, or some other label, to those users. A user can belong to any number of groups.

    A user in a group automatically has all the permissions granted to that group. For example, if the group Site editors has the permission can_edit_home_page, any user in that group will have that permission.

    Beyond permissions, groups are a convenient way to categorize users to apply some label, or extended functionality, to them. For example, you could create a group 'Special users', and you could write code that would do special things to those users -- such as giving them access to a members-only portion of your site, or sending them members-only e-mail messages.
    R1   R2   iP   t   uniqueR9   R5   t   blankR3   c           B   s    e  Z e d   Z e d  Z RS(   t   groupt   groups(   R%   R&   R8   R9   R:   (    (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR3   l   s   c         C   s   |  i  S(   N(   R1   (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR>   p   s    (    (   R%   R&   R@   R   RA   R8   t   TrueR1   t   ManyToManyFieldR0   R5   R3   R>   (    (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyRD   b   s
   !!t   UserManagerc           B   s,   e  Z d d   Z d   Z d d d  Z RS(   c         C   s   t  i  i   } y" | i   i d d  \ } } Wn t j
 o n Xd i | | i   g  } |  i d | d | d t d t	 d t d | d	 |  } | i
 |  | i d
 |  i  | S(   sX   
        Creates and saves a User with the given username, e-mail and password.
        t   @i   t   usernamet   emailt   is_stafft	   is_activet   is_superuserR   t   date_joinedt   using(   R   R   t   stripR   R   t   joint   lowerR/   t   FalseRI   t   set_passwordR   t   _db(   R-   RM   RN   t   passwordR   t
   email_namet   domain_partR!   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   create_usert   s    "	c         C   sG   |  i  | | |  } t | _ t | _ t | _ | i d |  i  | S(   NRS   (   R]   RI   RO   RP   RQ   R   RY   (   R-   RM   RN   RZ   t   u(    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   create_superuser   s    			i
   t7   abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789c         C   sD   d d k  l } d i g  } t |  D] } | | |  q' ~  S(   sI   Generates a random password with the given length and given allowed_charsi(   t   choicet    (   t   randomRa   RU   t   range(   R-   t   lengtht   allowed_charsRa   t   _[1]t   i(    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   make_random_password   s    N(   R%   R&   t   NoneR]   R_   Ri   (    (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyRK   s   s   	c         C   s   t    } |  i   } x t i   D]~ } | p
 | i of t | d  oR | d  j	 o+ | i o | i | i	 |  |   q q | i | i	 |    q q" q" W| S(   Nt   get_all_permissions(
   t   sett   is_anonymousR    t   get_backendst   supports_anonymous_usert   hasattrRj   t   supports_object_permissionst   updateRk   (   R!   t   objR5   t   anont   backend(    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   _user_get_all_permissions   s    	 
"c         C   s   |  i    } |  i } x t i   D] } | o | o
 | i p | p
 | i of t | d  oR | d  j	 o) | i o | i	 |  | |  o t
 Sq | i	 |  |  o t
 Sq q" q" Wt S(   Nt   has_perm(   Rm   RP   R    Rn   t   supports_inactive_userRo   Rp   Rj   Rq   Rw   RI   RW   (   R!   t   permRs   Rt   t   activeRu   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   _user_has_perm   s    	 
	c         C   s   |  i    } |  i } xp t i   D]b } | o | o
 | i p | p
 | i o0 t | d  o | i |  |  o t Sq q" q" Wt	 S(   Nt   has_module_perms(
   Rm   RP   R    Rn   Rx   Ro   Rp   R|   RI   RW   (   R!   R.   Rt   Rz   Ru   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   _user_has_module_perms   s    	 t   Userc        	   B   s  e  Z d  Z e i e d  d d d e d e d  Z e i e d  d d d e Z e i e d	  d d d e Z	 e i
 e d
  d e Z e i e d  d d d e d  Z e i e d  d e d e d  Z e i e d  d e d e d  Z e i e d  d e d e d  Z e i e d  d e i i Z e i e d  d e i i Z e i e d e d  d e d e d  Z e i e d e d  d e Z e   Z d d/ d     YZ d   Z d   Z  d   Z! d    Z" d!   Z# d"   Z$ d#   Z% d$   Z& d%   Z' d0 d&  Z) d0 d'  Z* d0 d(  Z+ d0 d)  Z, d*   Z- d+   Z. d0 d,  Z/ d-   Z0 d.   Z1 e2 e1  Z3 RS(1   s   
    Users within the Django authentication system are represented by this model.

    Username and password are required. Other fields are optional.
    RM   R2   i   RE   t	   help_textsK   Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characterss
   first nameRF   s	   last names   e-mail addressRZ   i   sX   Use '[algo]$[salt]$[hexdigest]' or use the <a href="password/">change password form</a>.s   staff statust   defaults9   Designates whether the user can log into this admin site.Rz   se   Designates whether this user should be treated as active. Unselect this instead of deleting accounts.s   superuser statussP   Designates that this user has all permissions without explicitly assigning them.s
   last logins   date joinedR9   RH   s}   In addition to the permissions manually assigned, this user will also get all permissions granted to each group he/she is in.s   user permissionsR3   c           B   s    e  Z e d   Z e d  Z RS(   R!   t   users(   R%   R&   R8   R9   R:   (    (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR3      s   c         C   s   |  i  S(   N(   RM   (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR>      s    c         C   s   d t  i t |  i   S(   Ns
   /users/%s/(   t   urllibt   quoteR   RM   (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   get_absolute_url   s    c         C   s   t  S(   sk   
        Always returns False. This is a way of comparing User objects to
        anonymous users.
        (   RW   (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyRm      s    c         C   s   t  S(   st   
        Always return True. This is a way to tell if the user has been
        authenticated in templates.
        (   RI   (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   is_authenticated   s    c         C   s    d |  i  |  i f } | i   S(   sC   Returns the first_name plus the last_name, with a space in between.u   %s %s(   t
   first_namet	   last_nameRT   (   R-   t	   full_name(    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   get_full_name   s    c         C   s   | d  j o |  i   ni d d  k } d } t | t | i    t | i     d  } t | | |  } d | | | f |  _ d  S(   NiR   i   s   %s$%s$%s(   Rj   t   set_unusable_passwordRc   R   t   strRZ   (   R-   R   Rc   R   R   R   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyRX      s    .c         C   sb   d |  i  j oB |  i  t d d |  j } | o |  i |  |  i   n | St | |  i   S(   s   
        Returns a boolean of whether the raw_password was correct. Handles
        encryption formats behind the scenes.
        R   R   Rb   (   RZ   R   RX   R   R   (   R-   R   t
   is_correct(    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR     s    c         C   s   t  |  _ d  S(   N(   t   UNUSABLE_PASSWORDRZ   (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR     s    c         C   s-   |  i  d  j p |  i  t j o t St Sd  S(   N(   RZ   Rj   R   RW   RI   (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   has_usable_password  s    c         C   s   t    } xv t i   D]h } t | d  oR | d j	 o+ | i o | i | i |  |   qz q~ | i | i |    q q W| S(   s   
        Returns a list of permission strings that this user has through
        his/her groups. This method queries all available auth backends.
        If an object is passed in, only permissions matching this object
        are returned.
        t   get_group_permissionsN(   Rl   R    Rn   Rp   Rj   Rq   Rr   R   (   R-   Rs   R5   Ru   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR      s    	 
c         C   s   t  |  |  S(   N(   Rv   (   R-   Rs   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyRk   3  s    c         C   s)   |  i  o |  i o t St |  | |  S(   s  
        Returns True if the user has the specified permission. This method
        queries all available auth backends, but returns immediately if any
        backend returns True. Thus, a user who has permission from a single
        auth backend is assumed to have permission in general. If an object
        is provided, permissions for this specific object are checked.
        (   RP   RQ   RI   R{   (   R-   Ry   Rs   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyRw   6  s    
c         C   s-   x& | D] } |  i  | |  p t Sq Wt S(   s   
        Returns True if the user has each of the specified permissions.
        If object is passed, it checks if the user has all required perms
        for this object.
        (   Rw   RW   RI   (   R-   t	   perm_listRs   Ry   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt	   has_permsF  s
     	c         C   s&   |  i  o |  i o t St |  |  S(   s   
        Returns True if the user has any permissions in the given app
        label. Uses pretty much the same logic as has_perm, above.
        (   RP   RQ   RI   R}   (   R-   R.   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR|   Q  s    c         C   s>   g  } x1 |  i  i   D]  } | i | i  | i   q W| S(   N(   t   message_sett   allt   appendt   messaget   delete(   R-   t   messagest   m(    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   get_and_delete_messages\  s     c         C   s-   d d k  l } | | | | |  i g  d S(   s   Sends an e-mail to this User.i(   t	   send_mailN(   t   django.core.mailR   RN   (   R-   t   subjectR   t
   from_emailR   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt
   email_userc  s    c      
   C   s  t  |  d  p d d k l } t | d t  p t d   n y | i i d  \ } } Wn t j
 o t d   n Xyi t	 i
 | |  } | d
 j o t d   n | i i |  i i  i d	 |  i  |  _ |  |  i _ Wqt t f j
 o t  qXn |  i S(   s   
        Returns site-specific profile for this user. Raises
        SiteProfileNotAvailable if this site does not allow profiles.
        t   _profile_cachei(   t   settingst   AUTH_PROFILE_MODULEs<   You need to set AUTH_PROFILE_MODULE in your project settingst   .sX   app_label and model_name should be separated by a dot in the AUTH_PROFILE_MODULE settingsT   Unable to load the profile model, check AUTH_PROFILE_MODULE in your project settingst   user__id__exactN(   Rp   t   django.confR   t   getattrRW   R$   R   R   R   R   t	   get_modelRj   t   _default_managerRS   t   _statet   dbR*   t   idR   R!   R   R   (   R-   R   R.   t
   model_nameR/   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   get_profileh  s"    *c         C   s&   d d  k  } | i d d t |  i S(   Nis`   The user messaging API is deprecated. Please update your code to use the new messages framework.t   category(   t   warningst   warnt   DeprecationWarningt   _message_set(   R-   R   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   _get_message_set  s    (    N(4   R%   R&   R@   R   RA   R8   RI   RM   R   R   t
   EmailFieldRN   RZ   t   BooleanFieldRW   RO   RP   RQ   t   DateTimeFieldR   R   R   RR   RJ   RD   RH   R0   t   user_permissionsRK   R+   R3   R>   R   Rm   R   R   RX   R   R   R   Rj   R   Rk   Rw   R   R|   R   R   R   R   t   propertyR   (    (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR~      sF   -!!''''!!!							
							t   Messagec           B   sA   e  Z d  Z e i e d d Z e i e d   Z	 d   Z
 RS(   s}  
    The message system is a lightweight way to queue messages for given
    users. A message is associated with a User instance (so it is only
    applicable for registered users). There's no concept of expiration or
    timestamps. Messages are created by the Django admin after successful
    actions. For example, "The poll Foo was created successfully." is a
    message.
    t   related_nameR   R   c         C   s   |  i  S(   N(   R   (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR>     s    (   R%   R&   R@   R   RB   R~   R!   t	   TextFieldR8   R   R>   (    (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR     s   t   AnonymousUserc           B   s  e  Z d Z d  Z e Z e Z e Z e	   Z
 e	   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d	   Z d
   Z d   Z e e  Z d   Z e e  Z d d  Z d d  Z d d  Z d d  Z d   Z d   Z  d   Z! d   Z" RS(   Rb   c         C   s   d  S(   N(    (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   __init__  s    c         C   s   d S(   NR   (    (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR>     s    c         C   s   t  |   i d  S(   Ns   utf-8(   R=   t   encode(   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   __str__  s    c         C   s   t  | |  i  S(   N(   t
   isinstancet	   __class__(   R-   t   other(    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   __eq__  s    c         C   s   |  i  |  S(   N(   R   (   R-   R   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   __ne__  s    c         C   s   d S(   Ni   (    (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   __hash__  s    c         C   s
   t   d  S(   N(   t   NotImplementedError(   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR     s    c         C   s
   t   d  S(   N(   R   (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR     s    c         C   s
   t   d  S(   N(   R   (   R-   R   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyRX     s    c         C   s
   t   d  S(   N(   R   (   R-   R   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR     s    c         C   s   |  i  S(   N(   t   _groups(   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   _get_groups  s    c         C   s   |  i  S(   N(   t   _user_permissions(   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   _get_user_permissions  s    c         C   s   t    S(   N(   Rl   (   R-   Rs   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR     s    c         C   s   t  |  d | S(   NRs   (   Rv   (   R-   Rs   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyRk     s    c         C   s   t  |  | d | S(   NRs   (   R{   (   R-   Ry   Rs   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyRw     s    c         C   s-   x& | D] } |  i  | |  p t Sq Wt S(   N(   Rw   RW   RI   (   R-   R   Rs   Ry   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR     s
     	c         C   s   t  |  |  S(   N(   R}   (   R-   t   module(    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR|     s    c         C   s   g  S(   N(    (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR     s    c         C   s   t  S(   N(   RI   (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyRm     s    c         C   s   t  S(   N(   RW   (   R-   (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR     s    N(#   R%   R&   Rj   R   RM   RW   RO   RP   RQ   R   R   R   R   R>   R   R   R   R   R   R   RX   R   R   R   RH   R   R   R   Rk   Rw   R   R|   R   Rm   R   (    (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyR     s:   																	(,   R   R   t   django.contribR    t   django.contrib.auth.signalsR   t   django.core.exceptionsR   t	   django.dbR   t   django.db.models.managerR   t"   django.contrib.contenttypes.modelsR   t   django.utils.encodingR   t   django.utils.hashcompatR   R   t   django.utils.translationR	   R8   t   django.utils.cryptoR
   R   R   R   R#   t   connectt	   ExceptionR$   t   ManagerR'   t   ModelR0   RD   RK   Rv   R{   R}   R~   R   t   objectR   (    (    (    sD   /usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.pyt   <module>   s6   			")			