Made a small improvement to django.views.core.flatfiles so that it only uses select_template if a custom template is available, so as not to hit the filesystem.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@677 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-09-23 22:09:42 +00:00
parent a39e6c91b1
commit 3dcdce4d63
1 changed files with 6 additions and 1 deletions

View File

@ -4,6 +4,8 @@ from django.models.core import flatfiles
from django.utils.httpwrappers import HttpResponse
from django.conf.settings import SITE_ID
DEFAULT_TEMPLATE = 'flatfiles/default'
def flat_file(request, url):
"""
Flat file view
@ -23,7 +25,10 @@ def flat_file(request, url):
if request.user.is_anonymous() and f.registration_required:
from django.views.auth.login import redirect_to_login
return redirect_to_login(request.path)
t = template_loader.select_template([f.template_name, 'flatfiles/default'])
if f.template_name:
t = template_loader.select_template((f.template_name, DEFAULT_TEMPLATE))
else:
t = template_loader.get_template(DEFAULT_TEMPLATE)
c = DjangoContext(request, {
'flatfile': f,
})