Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#15948 closed Cleanup/optimization (duplicate)

Regarding find_template_source()

Reported by: German M. Bravo Owned by: nobody
Component: Template system Version: 1.3
Severity: Normal Keywords:
Cc: German M. Bravo Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I still find myself in need of getting a template source, the current find_template returns a compiled template for the most part, and I would suggest keeping a working find_template_source for these edge cases as mine. Perhaps something like this is in place:

def find_template_source(name, dirs=None):
    if template_source_loaders is None:
        loaders = []
        for loader_name in settings.TEMPLATE_LOADERS:
            loader = find_template_loader(loader_name)
            if loader is not None:
        template_source_loaders = tuple(loaders)
    def load_template_source(loaders):
        for loader in loaders:
            if hasattr(loader, 'loaders'):
                    return load_template_source(loader.loaders)
                except TemplateDoesNotExist:
                    source, display_name = loader.load_template_source(name, dirs)
                    return (source, make_origin(display_name, loader, name, dirs))
                except TemplateDoesNotExist:
        raise TemplateDoesNotExist(name)
    return load_template_source(template_source_loaders)

Attachments (1)

#15948-find_template_source.diff (1.9 KB ) - added by German M. Bravo 13 years ago.

Download all attachments as: .zip

Change History (3)

by German M. Bravo, 13 years ago

comment:1 by Aymeric Augustin, 13 years ago

Resolution: duplicate
Status: newclosed

This looks very similar to #15102.

comment:2 by German M. Bravo, 12 years ago

Cc: German M. Bravo added
UI/UX: unset
Note: See TracTickets for help on using tickets.
Back to Top