Django

Code

Changeset 1399

Show
Ignore:
Timestamp:
11/24/05 15:14:42 (3 years ago)
Author:
adrian
Message:

Added a get_template_sources generator function to filesystem and app_directories template loaders, so template-loader debugger can hook into it. Refs #892.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/template/loader.py

    r1379 r1399  
    6060    for loader in template_source_loaders: 
    6161        try: 
    62             source, display_name = loader(name, dirs) 
     62            source, display_name = loader(name, dirs) 
    6363            return (source, make_origin(display_name, loader, name, dirs)) 
    6464        except TemplateDoesNotExist: 
  • django/trunk/django/core/template/loaders/app_directories.py

    r1379 r1399  
    2828app_template_dirs = tuple(app_template_dirs) 
    2929 
     30def 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) + TEMPLATE_FILE_EXTENSION 
     33 
    3034def load_template_source(template_name, template_dirs=None): 
    31     for template_dir in app_template_dirs: 
    32         filepath = os.path.join(template_dir, template_name) + TEMPLATE_FILE_EXTENSION 
     35    for filepath in get_template_sources(template_name, template_dirs): 
    3336        try: 
    3437            return (open(filepath).read(), filepath) 
  • django/trunk/django/core/template/loaders/filesystem.py

    r1379 r1399  
    55import os 
    66 
    7 def load_template_source(template_name, template_dirs=None): 
     7def get_template_sources(template_name, template_dirs=None): 
    88    if not template_dirs: 
    99        template_dirs = TEMPLATE_DIRS 
     10    for template_dir in template_dirs: 
     11        yield os.path.join(template_dir, template_name) + TEMPLATE_FILE_EXTENSION 
     12 
     13def load_template_source(template_name, template_dirs=None): 
    1014    tried = [] 
    11     for template_dir in template_dirs: 
    12         filepath = os.path.join(template_dir, template_name) + TEMPLATE_FILE_EXTENSION 
     15    for filepath in get_template_sources(template_name, template_dirs): 
    1316        try: 
    1417            return (open(filepath).read(), filepath)