Ticket #12557: supports_anonymous_users.diff

File supports_anonymous_users.diff, 1.8 KB (added by Harro, 15 years ago)

Patch for supports_anonymous_users flag on backends

  • django/contrib/auth/backends.py

     
    1212    Authenticates against django.contrib.auth.models.User.
    1313    """
    1414    supports_object_permissions = False
     15    supports_anonymous_users = False
    1516
    1617    # TODO: Model, login attribute name and password attribute name should be
    1718    # configurable.
  • django/contrib/auth/models.py

     
    397397    user_permissions = property(_get_user_permissions)
    398398
    399399    def has_perm(self, perm, obj=None):
     400        for backend in auth.get_backends():
     401            if backend.supports_anonymous_users:
     402                if hasattr(backend, "has_perm"):
     403                    if obj is not None:
     404                        if (backend.supports_object_permissions and
     405                            backend.has_perm(self, perm, obj)):
     406                                return True
     407                    else:
     408                        if backend.has_perm(self, perm):
     409                            return True
    400410        return False
    401411
    402412    def has_perms(self, perm_list, obj=None):
     413        for perm in perm_list:
     414            if not self.has_perm(perm, obj):
     415                return False
    403416        return False
    404417
    405418    def has_module_perms(self, module):
     419        for backend in auth.get_backends():
     420            if (backend.supports_anonymous_users and
     421                    hasattr(backend, "has_module_perms") and
     422                    backend.has_module_perms(self, app_label)):
     423                return True
    406424        return False
    407425
    408426    def get_and_delete_messages(self):
Back to Top