Django

Code

Changeset 3924

Show
Ignore:
Timestamp:
10/24/06 11:42:03 (2 years ago)
Author:
adrian
Message:

Fixed #2937 -- Added eq, ne and hash for AnonymousUser?. Thanks, favo@exoweb.net

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/auth/models.py

    r3885 r3924  
    127127        "Always returns False. This is a way of comparing User objects to anonymous users." 
    128128        return False 
    129      
     129 
    130130    def is_authenticated(self): 
    131131        """Always return True. This is a way to tell if the user has been authenticated in templates. 
     
    271271        return 'AnonymousUser' 
    272272 
     273    def __eq__(self, other): 
     274        return isinstance(other, self.__class__) 
     275 
     276    def __ne__(self, other): 
     277        return not self.__eq__(other) 
     278 
     279    def __hash__(self): 
     280        return 1 # instances always return the same hash value 
     281 
    273282    def save(self): 
    274283        raise NotImplementedError 
     
    302311    def is_anonymous(self): 
    303312        return True 
    304      
     313 
    305314    def is_authenticated(self): 
    306315        return False