Ticket #4952: 4952.2.diff
File 4952.2.diff, 2.5 KB (added by , 17 years ago) |
---|
-
django/template/loaders/app_directories.py
1 # Wrapper for loading templates from "template" directories in installed app packages. 1 """ 2 Wrapper for loading templates from "template" directories in INSTALLED_APPS 3 packages. 4 """ 2 5 6 import os 7 3 8 from django.conf import settings 4 9 from django.core.exceptions import ImproperlyConfigured 5 10 from django.template import TemplateDoesNotExist 6 import os7 11 8 12 # At compile time, cache the directories to search. 9 13 app_template_dirs = [] … … 28 32 app_template_dirs = tuple(app_template_dirs) 29 33 30 34 def get_template_sources(template_name, template_dirs=None): 31 for template_dir in app_template_dirs: 32 yield os.path.join(template_dir, template_name) 35 if not template_dirs: 36 template_dirs = app_template_dirs 37 for template_dir in template_dirs: 38 full_template_dir = os.path.join(template_dir, template_name) 39 # Security check to ensure that we are still in the template directory 40 # after the os.path.join. 41 if full_template_dir.startswith(template_dir): 42 yield full_template_dir 33 43 34 44 def load_template_source(template_name, template_dirs=None): 35 45 for filepath in get_template_sources(template_name, template_dirs): -
django/template/loaders/filesystem.py
1 # Wrapper for loading templates from the filesystem. 1 """ 2 Wrapper for loading templates from the filesystem. 3 """ 2 4 5 import os 6 3 7 from django.conf import settings 4 8 from django.template import TemplateDoesNotExist 5 import os6 9 7 10 def get_template_sources(template_name, template_dirs=None): 8 11 if not template_dirs: 9 12 template_dirs = settings.TEMPLATE_DIRS 10 13 for template_dir in template_dirs: 11 yield os.path.join(template_dir, template_name) 14 full_template_dir = os.path.join(template_dir, template_name) 15 # Security check to ensure that we are still in the template directory 16 # after the os.path.join. 17 if full_template_dir.startswith(template_dir): 18 yield full_template_dir 12 19 13 20 def load_template_source(template_name, template_dirs=None): 14 21 tried = []