Ticket #7553: 7553-sites-decorators-ref.2.diff

File 7553-sites-decorators-ref.2.diff, 2.5 KB (added by Michael Newman, 16 years ago)

Updated based on brosner's comments

  • django/views/decorators/cache.py

     
    4242    """
    4343    def _wrapped_view_func(request, *args, **kwargs):
    4444        response = view_func(request, *args, **kwargs)
    45         # Although rare, it is possible for a view to return None (e.g. the
    46         # django.contrib.admin.sites.AdminSite.login view in one corner-case)
    47         if response:
    48             add_never_cache_headers(response)
     45        add_never_cache_headers(response)
    4946        return response
    5047    return wraps(view_func)(_wrapped_view_func)
  • django/contrib/admin/sites.py

     
    118118        # The 'logout' view doesn't require that the person is logged in.
    119119        if url == 'logout':
    120120            return self.logout(request)
    121 
     121       
     122        # Check for permission or show login form
    122123        if not self.has_permission(request):
    123             response = self.login(request)
    124             if response:
    125                 # make sure that there is a response before returning
    126                 # this addresses any post data that might persist from
    127                 # expired sessions and continue through (#5999)
    128                 return response
     124            return self.login(request)
    129125
    130126        if url == '':
    131127            return self.index(request)
     
    257253                user.last_login = datetime.datetime.now()
    258254                user.save()
    259255                if request.POST.has_key('post_data'):
     256                    request.session.delete_test_cookie()
    260257                    post_data = _decode_post_data(request.POST['post_data'])
    261258                    if post_data and not post_data.has_key(LOGIN_FORM_KEY):
    262259                        # overwrite request.POST with the saved post_data, and continue
    263260                        request.POST = post_data
    264261                        request.user = user
    265                         return None
     262                        return self.root(request, request.path.split(self.root_path)[-1])
    266263                    else:
    267                         request.session.delete_test_cookie()
    268264                        return http.HttpResponseRedirect(request.path)
    269265            else:
    270266                return self.display_login_form(request, ERROR_MESSAGE)
Back to Top