Added friendly error message if a view returns None instead of an HttpResponse object.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@531 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-08-18 00:14:15 +00:00
parent f5ab1320ed
commit 8a939224fa
1 changed files with 9 additions and 1 deletions

View File

@ -54,12 +54,20 @@ class BaseHandler:
resolver = urlresolvers.RegexURLResolver(r'^/', ROOT_URLCONF)
try:
callback, param_dict = resolver.resolve(path)
# Apply view middleware
for middleware_method in self._view_middleware:
response = middleware_method(request, callback, param_dict)
if response:
return response
return callback(request, **param_dict)
response = callback(request, **param_dict)
# Complain if the view returned None (a common error).
if not response:
raise ValueError, "The view %s.%s didn't return an HttpResponse object." % (callback.__module__, callback.func_name)
return response
except exceptions.Http404, e:
if DEBUG:
return self.get_technical_error_response(is404=True, exception=e)