Ticket #1496: compare-users.diff

File compare-users.diff, 1.1 KB (added by Antti Kaihola, 19 years ago)

models.User and middleware.UserWrapper equality tests for contrib.auth

  • django/contrib/auth/middleware.py

     
    1717    def __getattr__(self, name):
    1818        return getattr(self._user, name)
    1919
     20    def __eq__(self, other):
     21        return self._get_user() == other
     22
     23    def __eq__(self, other):
     24        return self._get_user() != other
     25
    2026class AuthenticationMiddleware:
    2127    def process_request(self, request):
    2228        from django.contrib.auth.models import SESSION_KEY
  • django/contrib/auth/models.py

     
    214214                    raise SiteProfileNotAvailable
    215215        return self._profile_cache
    216216
     217    def __eq__(self, other):
     218        return self.id == other.id
     219
     220    def __ne__(self, other):
     221        return self.id != other.id
     222
    217223class Message(models.Model):
    218224    user = models.ForeignKey(User)
    219225    message = models.TextField(_('Message'))
Back to Top