Ticket #7553: 7553-sites-decorators-excpt.diff
File 7553-sites-decorators-excpt.diff, 3.7 KB (added by , 16 years ago) |
---|
-
django/views/decorators/cache.py
42 42 """ 43 43 def _wrapped_view_func(request, *args, **kwargs): 44 44 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) 49 46 return response 50 47 return wraps(view_func)(_wrapped_view_func) -
django/contrib/admin/sites.py
24 24 class NotRegistered(Exception): 25 25 pass 26 26 27 class PostDataFallThrough(Exception): 28 pass 29 27 30 def _encode_post_data(post_data): 28 31 from django.conf import settings 29 32 pickled = pickle.dumps(post_data) … … 71 74 model_or_iterable = [model_or_iterable] 72 75 for model in model_or_iterable: 73 76 if model in self._registry: 74 raise AlreadyRegistered ('The model %s is already registered' % model.__name__)77 raise AlreadyRegistered, _('The model %s is already registered') % model.__name__ 75 78 self._registry[model] = admin_class(model, self) 76 79 77 80 def unregister(self, model_or_iterable): … … 84 87 model_or_iterable = [model_or_iterable] 85 88 for model in model_or_iterable: 86 89 if model not in self._registry: 87 raise NotRegistered ('The model %s is not registered' % model.__name__)90 raise NotRegistered, _('The model %s is not registered') % model.__name__ 88 91 del self._registry[model] 89 92 90 93 def has_permission(self, request): … … 111 114 # The 'logout' view doesn't require that the person is logged in. 112 115 if url == 'logout': 113 116 return self.logout(request) 114 117 118 # Check for permission or show login form 115 119 if not self.has_permission(request): 116 response = self.login(request) 117 if response: 118 # make sure that there is a response before returning 119 # this addresses any post data that might persist from 120 # expired sessions and continue through (#5999) 120 try: 121 response = self.login(request) 121 122 return response 123 except PostDataFallThrough: 124 # exception for a form that carries post data 125 pass 122 126 123 127 if url == '': 124 128 return self.index(request) … … 250 254 user.last_login = datetime.datetime.now() 251 255 user.save() 252 256 if request.POST.has_key('post_data'): 257 request.session.delete_test_cookie() 253 258 post_data = _decode_post_data(request.POST['post_data']) 254 259 if post_data and not post_data.has_key(LOGIN_FORM_KEY): 255 260 # overwrite request.POST with the saved post_data, and continue 256 261 request.POST = post_data 257 262 request.user = user 258 r eturn None263 raise PostDataFallThrough 259 264 else: 260 request.session.delete_test_cookie()261 265 return http.HttpResponseRedirect(request.path) 262 266 else: 263 267 return self.display_login_form(request, ERROR_MESSAGE)