Code

Opened 3 years ago

Closed 3 years ago

Last modified 2 years ago

#15948 closed Cleanup/optimization (duplicate)

Regarding find_template_source()

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

Description

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:
                loaders.append(loader)
        template_source_loaders = tuple(loaders)
    def load_template_source(loaders):
        for loader in loaders:
            if hasattr(loader, 'loaders'):
                try:
                    return load_template_source(loader.loaders)
                except TemplateDoesNotExist:
                    pass
            else:
                try:
                    source, display_name = loader.load_template_source(name, dirs)
                    return (source, make_origin(display_name, loader, name, dirs))
                except TemplateDoesNotExist:
                    pass
        raise TemplateDoesNotExist(name)
    return load_template_source(template_source_loaders)

Attachments (1)

#15948-find_template_source.diff (1.9 KB) - added by Kronuz 3 years ago.

Download all attachments as: .zip

Change History (3)

Changed 3 years ago by Kronuz

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

This looks very similar to #15102.

comment:2 Changed 2 years ago by Kronuz

  • Cc Kronuz added
  • UI/UX unset

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.