Ticket #4049: AuthenticationMiddleware.diff

File AuthenticationMiddleware.diff, 910 bytes (added by Grzegorz Ślusarek, 13 years ago)

patch against revision 6213

  • django/core/context_processors.py

     
    1212def auth(request):
    1313    """
    1414    Returns context variables required by apps that use Django's authentication
    15     system.
     15    system. Function  check that request has an attribute 'user' added by
     16    presumably middleware or other code, if not return empty dictionary.
    1617    """
    17     return {
    18         'user': request.user,
    19         'messages': request.user.get_and_delete_messages(),
    20         'perms': PermWrapper(request.user),
    21     }
     18    try:
     19        return {
     20            'user': request.user,
     21            'messages': request.user.get_and_delete_messages(),
     22            'perms': PermWrapper(request.user),
     23        }
     24    except AttributeError:
     25        return {}
Back to Top