Beispiel #1
0
def load_template_source(templateName, templateDirs=None):
    if not templateDirs:
        templateDirs = list(settings.TEMPLATE_DIRS)

    parts = templateName.split(":")

    if len(parts) > 1:
        if len(parts) == 3:
            folder, sub, name = parts
        elif len(parts) == 2:
            folder, name = parts
            sub = None
        else:
            raise Exception("Must only have one or two ':' in template name")

        location = {
            'spikes': settings.SPIKEDIR,
            'examples': settings.EXAMPLEDIR,
        }.get(folder, None)

        if not location:
            raise Exception("No such location as %s" % location)

        if sub:
            location = '/'.join([location, sub])

        templateDirs = [location] + templateDirs
        templateName = name

    return django_load_template_source(templateName, templateDirs)
Beispiel #2
0
def load_template_source(templateName, templateDirs=None):
    if not templateDirs:
        templateDirs = list(settings.TEMPLATE_DIRS)
    
    parts = templateName.split(":")
    
    if len(parts) > 1:
        if len(parts) == 3:
            folder, sub, name = parts
        elif len(parts) == 2:
            folder, name = parts
            sub = None
        else:
            raise Exception("Must only have one or two ':' in template name")
    
        
        location = {
            'spikes'   : settings.SPIKEDIR,
            'examples' : settings.EXAMPLEDIR,
        }.get(folder, None)
        
        if not location:
            raise Exception("No such location as %s" % location)
    
        if sub:
            location = '/'.join([location, sub])
        
        templateDirs = [location] + templateDirs
        templateName = name
    
    return django_load_template_source(templateName, templateDirs)
Beispiel #3
0
def load_template_source(template_name, template_dirs=None):
    """
    Tries to load the template from the dbtemplates cache backend specified
    by the DBTEMPLATES_CACHE_BACKEND setting. If it does not find a template
    it falls back to query the database field ``name`` with the template path
    and ``sites`` with the current site.
    """
    cachename = 'current_theme'
    timeout = 60*60*24

    theme = cache.get(cachename)
    if theme is None:
    	theme= Theme.objects.get_current() #or Settings.get_current_theme()
        cache.set(cachename, theme, timeout)
    
    theme_dir = "default"
    if theme:
        theme_dir= theme.path
    
    template_dirs = [ os.path.join(settings.THEME_ROOT, theme_dir, 'templates'),]
    return django_load_template_source(template_name, template_dirs)
Beispiel #4
0
def load_template_source(template_name, template_dirs=None):
    """
    Tries to load the template from the dbtemplates cache backend specified
    by the DBTEMPLATES_CACHE_BACKEND setting. If it does not find a template
    it falls back to query the database field ``name`` with the template path
    and ``sites`` with the current site.
    """
    cachename = 'current_theme'
    timeout = 60 * 60 * 24

    theme = cache.get(cachename)
    if theme is None:
        theme = Theme.objects.get_current()  #or Settings.get_current_theme()
        cache.set(cachename, theme, timeout)

    theme_dir = "default"
    if theme:
        theme_dir = theme.path

    template_dirs = [
        os.path.join(settings.THEME_ROOT, theme_dir, 'templates'),
    ]
    return django_load_template_source(template_name, template_dirs)