--- E:\python\django-app\django\django\contrib\auth\models.py	Fri Oct 24 19:29:51 2008
+++ E:\webdev\django\contrib\auth\models.py	Fri Oct 24 19:35:06 2008
@@ -147,23 +147,35 @@
         return self.username
 
     def get_absolute_url(self):
+        if self.username == 'BuiltinDjangoAnonymousUser':
+            return '/'
+            
         return "/users/%s/" % urllib.quote(smart_str(self.username))
 
     def is_anonymous(self):
-        "Always returns False. This is a way of comparing User objects to anonymous users."
+        "Return True if it is the Anonymous users, False if not"
+        if self.username == 'BuiltinDjangoAnonymousUser':
+            return True
         return False
 
     def is_authenticated(self):
-        """Always return True. This is a way to tell if the user has been authenticated in templates.
+        """Return True for loged in users and False of the Anon Users. This is a way to tell if the user has been authenticated in templates.
         """
+        if self.username == 'BuiltinDjangoAnonymousUser':
+            return False
         return True
 
     def get_full_name(self):
-        "Returns the first_name plus the last_name, with a space in between."
+        "Returns the first_name plus the last_name, with a space in between."        
         full_name = u'%s %s' % (self.first_name, self.last_name)
         return full_name.strip()
 
     def set_password(self, raw_password):
+        """
+        Set the password for the user, just return if it is the Anon User
+        """
+        if self.username == 'BuiltinDjangoAnonymousUser':
+            return
         import random
         algo = 'sha1'
         salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]
@@ -174,7 +186,10 @@
         """
         Returns a boolean of whether the raw_password was correct. Handles
         encryption formats behind the scenes.
+        Always return False for the Anon user since people cannot login as that user
         """
+        if self.username == 'BuiltinDjangoAnonymousUser':
+            return False
         # Backwards-compatibility check. Older passwords won't include the
         # algorithm or salt.
         if '$' not in self.password:
@@ -197,6 +212,9 @@
         """
         Returns a list of permission strings that this user has through
         his/her groups. This method queries all available auth backends.
+        Not special casing the Anon user for groups or permissions because
+        the whole point of actualy having the Anon user is so you can setup
+        permissions for it
         """
         permissions = set()
         for backend in auth.get_backends():
@@ -217,6 +235,9 @@
         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.
+        Not special casing the Anon user for groups or permissions because
+        the whole point of actualy having the Anon user is so you can setup
+        permissions for it
         """
         # Inactive users have no permissions.
         if not self.is_active:
@@ -234,7 +255,12 @@
         return False
 
     def has_perms(self, perm_list):
-        """Returns True if the user has each of the specified permissions."""
+        """
+        Returns True if the user has each of the specified permissions.
+        Not special casing the Anon user for groups or permissions because
+        the whole point of actualy having the Anon user is so you can setup
+        permissions for it
+        """
         for perm in perm_list:
             if not self.has_perm(perm):
                 return False
@@ -244,6 +270,9 @@
         """
         Returns True if the user has any permissions in the given app
         label. Uses pretty much the same logic as has_perm, above.
+        Not special casing the Anon user for groups or permissions because
+        the whole point of actualy having the Anon user is so you can setup
+        permissions for it
         """
         if not self.is_active:
             return False
@@ -265,7 +294,12 @@
         return messages
 
     def email_user(self, subject, message, from_email=None):
-        "Sends an e-mail to this User."
+        """
+        Sends an e-mail to this User.
+        Dont try to sent to the Anon User
+        """
+        if self.username == 'BuiltinDjangoAnonymousUser':
+            return
         from django.core.mail import send_mail
         send_mail(subject, message, from_email, [self.email])
 
@@ -273,7 +307,11 @@
         """
         Returns site-specific profile for this user. Raises
         SiteProfileNotAvailable if this site does not allow profiles.
+        Anon cannot have a profile either
         """
+        if self.username == 'BuiltinDjangoAnonymousUser':
+            raise SiteProfileNotAvailable
+            
         if not hasattr(self, '_profile_cache'):
             from django.conf import settings
             if not getattr(settings, 'AUTH_PROFILE_MODULE', False):
@@ -302,7 +340,7 @@
     def __unicode__(self):
         return self.message
 
-class AnonymousUser(object):
+class AnonymousUserClass(object):
     id = None
     username = ''
     is_staff = False
@@ -366,3 +404,9 @@
 
     def is_authenticated(self):
         return False
+        
+def AnonymousUser():
+    try:
+        return User.objects.get(username__exact='BuiltinDjangoAnonymousUser')
+    except:
+        return AnonymousUserClass()
