Ejemplo n.º 1
0
    def get_loaders(self):
        try:
            from django.template.loader import find_template as finder_func
        except ImportError:
            from django.template.loader import find_template_source as finder_func
        try:
            # Force Django to calculate template_source_loaders from
            # TEMPLATE_LOADERS settings, by asking to find a dummy template
            finder_func("test")
        # Had to transform this Exception, because otherwise even if there
        # was a try catch it was crashing, this is a broad Exception but at
        # it does what the try catch does by not crashing the command line
        # execution.
        except Exception:
            pass
        loaders = []
        # At the top when you first import template_source_loaders it is set
        # to None, because in django that is what it is set too. While it
        # executes the finder_func it is setting the template_source_loaders
        # I needed to re-import the value of it at this point because it was
        # still None and importing it again made it filled with the proper
        # django default values.
        from django.template.loader import template_source_loaders

        for loader in template_source_loaders:
            if hasattr(loader, "loaders"):
                loaders.extend(loader.loaders)
            else:
                loaders.append(loader)
        return loaders
Ejemplo n.º 2
0
 def get_loaders(self):
     from django.template.loader import template_source_loaders
     if template_source_loaders is None:
         try:
             from django.template.loader import (find_template as
                                                 finder_func)
         except ImportError:
             from django.template.loader import (find_template_source as
                                                 finder_func)
         try:
             source, name = finder_func('test')
         except TemplateDoesNotExist:
             pass
         from django.template.loader import template_source_loaders
     loaders = []
     # If template loader is CachedTemplateLoader, return the loaders
     # that it wraps around. So if we have
     # TEMPLATE_LOADERS = (
     #    ('django.template.loaders.cached.Loader', (
     #        'django.template.loaders.filesystem.Loader',
     #        'django.template.loaders.app_directories.Loader',
     #    )),
     # )
     # The loaders will return django.template.loaders.filesystem.Loader
     # and django.template.loaders.app_directories.Loader
     for loader in template_source_loaders:
         if CachedLoader is not None and isinstance(loader, CachedLoader):
             loaders.extend(loader.loaders)
         else:
             loaders.append(loader)
     return loaders
Ejemplo n.º 3
0
 def get_loaders(self):
     try:
         from django.template.loader import (
             find_template as finder_func)
     except ImportError:
         from django.template.loader import (find_template_source as finder_func)
     try:
         # Force Django to calculate template_source_loaders from
         # TEMPLATE_LOADERS settings, by asking to find a dummy template
         finder_func('test')
     # Had to transform this Exception, because otherwise even if there
     # was a try catch it was crashing, this is a broad Exception but at
     # it does what the try catch does by not crashing the command line
     # execution.
     except Exception, e:
         pass
    def get_loaders(self):
        from django.template.loader import template_source_loaders

        if template_source_loaders is None:
            try:
                from django.template.loader import find_template as finder_func
            except ImportError:
                from django.template.loader import find_template_source as finder_func  # noqa
            try:
                # Force django to calculate template_source_loaders from
                # TEMPLATE_LOADERS settings, by asking to find a dummy template
                source, name = finder_func("test")
            except TemplateDoesNotExist:
                pass
            # Reload template_source_loaders now that it has been calculated ;
            # it should contain the list of valid, instantiated template loaders
            # to use.
            from django.template.loader import template_source_loaders
        loaders = []
        # If template loader is CachedTemplateLoader, return the loaders
        # that it wraps around. So if we have
        # TEMPLATE_LOADERS = (
        #    ('django.template.loaders.cached.Loader', (
        #        'django.template.loaders.filesystem.Loader',
        #        'django.template.loaders.app_directories.Loader',
        #    )),
        # )
        # The loaders will return django.template.loaders.filesystem.Loader
        # and django.template.loaders.app_directories.Loader
        for loader in template_source_loaders:
            if CachedLoader is not None and isinstance(loader, CachedLoader):
                loaders.extend(loader.loaders)
            else:
                loaders.append(loader)
        return loaders
Ejemplo n.º 5
0
 def get_loaders(self):
     from django.template.loader import template_source_loaders
     if template_source_loaders is None:
         try:
             from django.template.loader import (
                 find_template as finder_func)
         except ImportError:
             from django.template.loader import (
                 find_template_source as finder_func)
         try:
             source, name = finder_func('test')
         except TemplateDoesNotExist:
             pass
         from django.template.loader import template_source_loaders
     loaders = []
     # If template loader is CachedTemplateLoader, return the loaders
     # that it wraps around. So if we have 
     # TEMPLATE_LOADERS = (
     #    ('django.template.loaders.cached.Loader', (
     #        'django.template.loaders.filesystem.Loader',
     #        'django.template.loaders.app_directories.Loader',
     #    )),
     # )
     # The loaders will return django.template.loaders.filesystem.Loader
     # and django.template.loaders.app_directories.Loader
     for loader in template_source_loaders:
         if isinstance(loader, CachedLoader):
             loaders.extend(loader.loaders)
         else:
             loaders.append(loader)
     return loaders
Ejemplo n.º 6
0
 def get_loaders(self):
     from django.template.loader import template_source_loaders
     if template_source_loaders is None:
         try:
             from django.template.loader import (
                 find_template as finder_func)
         except ImportError:
             from django.template.loader import (find_template_source as finder_func)
         try:
             # Force Django to calculate template_source_loaders from
             # TEMPLATE_LOADERS settings, by asking to find a dummy template
             finder_func('test')
         except TemplateDoesNotExist:
             pass
     loaders = []
     for loader in template_source_loaders:
         if hasattr(loader, 'loaders'):
             loaders.extend(loader.loaders)
         else:
             loaders.append(loader)
     return loaders
Ejemplo n.º 7
0
 def get_loaders(self):
     from django.template.loader import template_source_loaders
     if template_source_loaders is None:
         try:
             from django.template.loader import find_template as finder_func
         except ImportError:
             from django.template.loader import find_template_source as finder_func
         try:
             source, name = finder_func('test')
         except TemplateDoesNotExist, e:
             pass
         from django.template.loader import template_source_loaders
Ejemplo n.º 8
0
 def get_loaders(self):
     from django.template.loader import template_source_loaders
     if template_source_loaders is None:
         try:
             from django.template.loader import find_template as finder_func
         except ImportError:
             from django.template.loader import find_template_source as finder_func
         try:
             source, name = finder_func('test')
         except TemplateDoesNotExist:
             pass
         from django.template.loader import template_source_loaders
     return template_source_loaders or []
Ejemplo n.º 9
0
def get_loaders():
    from django.template.loader import template_source_loaders
    if template_source_loaders is None:
        try:
            from django.template.loader import (
                find_template as finder_func)
        except ImportError:
            from django.template.loader import (
                find_template_source as finder_func)
        try:
            source, name = finder_func('test')
        except TemplateDoesNotExist:
            pass
        from django.template.loader import template_source_loaders
    return template_source_loaders or []
 def get_loaders(self):
     if django.VERSION < (1, 8):
         from django.template.base import TemplateDoesNotExist as DjangoTemplateDoesNotExist
         from django.template.loader import template_source_loaders
         if template_source_loaders is None:
             try:
                 from django.template.loader import (
                     find_template as finder_func)
             except ImportError:
                 from django.template.loader import (
                     find_template_source as finder_func)  # noqa
             try:
                 # Force django to calculate template_source_loaders from
                 # TEMPLATE_LOADERS settings, by asking to find a dummy template
                 source, name = finder_func('test')
             except DjangoTemplateDoesNotExist:
                 pass
             # Reload template_source_loaders now that it has been calculated ;
             # it should contain the list of valid, instanciated template loaders
             # to use.
             from django.template.loader import template_source_loaders
     else:
         from django.template import engines
         template_source_loaders = []
         for e in engines.all():
             template_source_loaders.extend(e.engine.get_template_loaders(e.engine.loaders))
     loaders = []
     # If template loader is CachedTemplateLoader, return the loaders
     # that it wraps around. So if we have
     # TEMPLATE_LOADERS = (
     #    ('django.template.loaders.cached.Loader', (
     #        'django.template.loaders.filesystem.Loader',
     #        'django.template.loaders.app_directories.Loader',
     #    )),
     # )
     # The loaders will return django.template.loaders.filesystem.Loader
     # and django.template.loaders.app_directories.Loader
     # The cached Loader and similar ones include a 'loaders' attribute
     # so we look for that.
     for loader in template_source_loaders:
         if hasattr(loader, 'loaders'):
             loaders.extend(loader.loaders)
         else:
             loaders.append(loader)
     return loaders
Ejemplo n.º 11
0
 def get_loaders(self):
     if django.VERSION < (1, 8):
         from django.template.base import TemplateDoesNotExist as DjangoTemplateDoesNotExist
         from django.template.loader import template_source_loaders
         if template_source_loaders is None:
             try:
                 from django.template.loader import (
                     find_template as finder_func)
             except ImportError:
                 from django.template.loader import (
                     find_template_source as finder_func)  # noqa
             try:
                 # Force django to calculate template_source_loaders from
                 # TEMPLATE_LOADERS settings, by asking to find a dummy template
                 source, name = finder_func('test')
             except DjangoTemplateDoesNotExist:
                 pass
             # Reload template_source_loaders now that it has been calculated ;
             # it should contain the list of valid, instanciated template loaders
             # to use.
             from django.template.loader import template_source_loaders
     else:
         from django.template import engines
         template_source_loaders = []
         for e in engines.all():
             template_source_loaders.extend(e.engine.get_template_loaders(e.engine.loaders))
     loaders = []
     # If template loader is CachedTemplateLoader, return the loaders
     # that it wraps around. So if we have
     # TEMPLATE_LOADERS = (
     #    ('django.template.loaders.cached.Loader', (
     #        'django.template.loaders.filesystem.Loader',
     #        'django.template.loaders.app_directories.Loader',
     #    )),
     # )
     # The loaders will return django.template.loaders.filesystem.Loader
     # and django.template.loaders.app_directories.Loader
     # The cached Loader and similar ones include a 'loaders' attribute
     # so we look for that.
     for loader in template_source_loaders:
         if hasattr(loader, 'loaders'):
             loaders.extend(loader.loaders)
         else:
             loaders.append(loader)
     return loaders
Ejemplo n.º 12
0
 def get_loaders(self):
     from django.template.loader import template_source_loaders
     if template_source_loaders is None:
         try:
             from django.template.loader import (find_template as
                                                 finder_func)
         except ImportError:
             from django.template.loader import (find_template_source as
                                                 finder_func)  # noqa
         try:
             # Force django to calculate template_source_loaders from
             # TEMPLATE_LOADERS settings, by asking to find a dummy template
             source, name = finder_func('test')
         except TemplateDoesNotExist:
             pass
         # Reload template_source_loaders now that it has been calculated ;
         # it should contain the list of valid, instanciated template loaders
         # to use.
         from django.template.loader import template_source_loaders
     loaders = []
     # If template loader is CachedTemplateLoader, return the loaders
     # that it wraps around. So if we have
     # TEMPLATE_LOADERS = (
     #    ('django.template.loaders.cached.Loader', (
     #        'django.template.loaders.filesystem.Loader',
     #        'django.template.loaders.app_directories.Loader',
     #    )),
     # )
     # The loaders will return django.template.loaders.filesystem.Loader
     # and django.template.loaders.app_directories.Loader
     for loader in template_source_loaders:
         if CachedLoader is not None and isinstance(loader, CachedLoader):
             loaders.extend(loader.loaders)
         else:
             loaders.append(loader)
     return loaders