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

File common-parent-class-for-user-and-anonymoususer.patch, 3.5 KB (added by Joshua "jag" Ginsberg <jag@…>, 16 years ago)

Patchfile

  • 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 UserObject(object):
    322381    id = None
    323382    username = ''
    324383    is_staff = False
    325384    is_active = True
    326385    is_superuser = False
     386   
     387    def __init__(self):
     388        raise NotImplementedError
     389
     390    def __unicode__(self):
     391        raise NotImplementedError
     392
     393    def __str__(self):
     394        raise NotImplementedError
     395
     396    def __eq__(self, other):
     397        raise NotImplementedError
     398
     399    def __ne__(self, other):
     400        raise NotImplementedError
     401
     402    def __hash__(self):
     403        raise NotImplementedError
     404
     405    def save(self):
     406        raise NotImplementedError
     407
     408    def delete(self):
     409        raise NotImplementedError
     410
     411    def set_password(self, raw_password):
     412        raise NotImplementedError
     413
     414    def check_password(self, raw_password):
     415        raise NotImplementedError
     416
     417    def groups(self):
     418        raise NotImplementedError
     419   
     420    def user_permissions(self):
     421        raise NotImplementedError
     422
     423    def has_perm(self, perm):
     424        raise NotImplementedError
     425
     426    def has_module_perms(self, module):
     427        raise NotImplementedError
     428
     429    def get_and_delete_messages(self):
     430        raise NotImplementedError
     431
     432    def is_anonymous(self):
     433        raise NotImplementedError
     434
     435    def is_authenticated(self):
     436        raise NotImpelementedError
     437
     438
     439class AnonymousUser(UserClass):
     440    id = None
     441    username = ''
     442    is_staff = False
     443    is_active = True
     444    is_superuser = False
    327445    _groups = EmptyManager()
    328446    _user_permissions = EmptyManager()
    329447
Back to Top