Beispiel #1
0
    def load_template_source(self, template_name, template_dirs=None):
        tried = []
        if not template_dirs:
            device = get_current_device()
            if device and device.is_featurephone:
                template_dirs = settings.TEMPLATE_DIRS
            else:
                template_dirs = settings.SMARTPHONE_TEMPLATE_DIRS

        for filepath in self.get_template_sources(template_name,
                                                  template_dirs):
            try:
                file = open(filepath)
                try:
                    return (replace_entity(file.read().decode(
                        settings.FILE_CHARSET)), filepath)
                finally:
                    file.close()
            except IOError:
                tried.append(filepath)
        if tried:
            error_msg = "Tried %s" % tried
        else:
            error_msg = "Your TEMPLATE_DIRS setting is empty. Change it to point to at least one template directory."
        raise TemplateDoesNotExist(error_msg)
Beispiel #2
0
    def load_template_source(self, template_name, template_dirs=None):
        tried = []
        if not template_dirs:
            device = get_current_device()
            if device and device.is_featurephone:
                template_dirs = settings.TEMPLATE_DIRS
            else:
                template_dirs = settings.SMARTPHONE_TEMPLATE_DIRS

        for filepath in self.get_template_sources(template_name, template_dirs):
            try:
                file = open(filepath)
                try:
                    return (replace_entity(file.read().decode(settings.FILE_CHARSET)), filepath)
                finally:
                    file.close()
            except IOError:
                tried.append(filepath)
        if tried:
            error_msg = "Tried %s" % tried
        else:
            error_msg = "Your TEMPLATE_DIRS setting is empty. Change it to point to at least one template directory."
        raise TemplateDoesNotExist(error_msg)
Beispiel #3
0
def load_template_source(template_name, template_dirs=None):
    content, filepath = _load(template_name, template_dirs)
    content = replace_entity(content)
    return content, filepath
Beispiel #4
0
def load_template_source(template_name, template_dirs=None):
    content, filepath = _load(template_name, template_dirs)
    content = replace_entity(content)
    return content, filepath