Ticket #5921: common-parent-class-for-user-and-anonymoususer.2.patch

File common-parent-class-for-user-and-anonymoususer.2.patch, 2.1 KB (added by Joshua "jag" Ginsberg <jag@…>, 16 years ago)
  • django/contrib/auth/models.py

     
    123123        from random import choice
    124124        return ''.join([choice(allowed_chars) for i in range(length)])
    125125
    126 class User(models.Model):
     126class UserClass(object):
     127    id = None
     128    username = ''
     129    is_staff = False
     130    is_active = True
     131    is_superuser = False
     132   
     133    def __init__(self):
     134        raise NotImplementedError, _(('UserClass is an abstract class. Use '
     135                                      'either User or AnonymousUser instead.'))
     136
     137    def __unicode__(self):
     138        raise NotImplementedError
     139
     140    def __str__(self):
     141        raise NotImplementedError
     142
     143    def __eq__(self, other):
     144        raise NotImplementedError
     145
     146    def __ne__(self, other):
     147        raise NotImplementedError
     148
     149    def __hash__(self):
     150        raise NotImplementedError
     151
     152    def save(self):
     153        raise NotImplementedError
     154
     155    def delete(self):
     156        raise NotImplementedError
     157
     158    def set_password(self, raw_password):
     159        raise NotImplementedError
     160
     161    def check_password(self, raw_password):
     162        raise NotImplementedError
     163
     164    def groups(self):
     165        raise NotImplementedError
     166   
     167    def user_permissions(self):
     168        raise NotImplementedError
     169
     170    def has_perm(self, perm):
     171        raise NotImplementedError
     172
     173    def has_module_perms(self, module):
     174        raise NotImplementedError
     175
     176    def get_and_delete_messages(self):
     177        raise NotImplementedError
     178
     179    def is_anonymous(self):
     180        raise NotImplementedError
     181
     182    def is_authenticated(self):
     183        raise NotImpelementedError
     184
     185class User(models.Model, UserClass):
    127186    """Users within the Django authentication system are represented by this model.
    128187
    129188    Username and password are required. Other fields are optional.
     
    318377    def __unicode__(self):
    319378        return self.message
    320379
    321 class AnonymousUser(object):
     380class AnonymousUser(UserClass):
    322381    id = None
    323382    username = ''
    324383    is_staff = False
Back to Top