Exemplo n.º 1
0
    def render(self, context):
        source = self.nodelist.render(context)

        if USE_CACHE:
            cache_key = get_cache_key(get_hexdigest(source))
            cached = cache.get(cache_key, None)
            if cached is not None:
                return cached
            output = self.compiler.compile_source(source)
            cache.set(cache_key, output, CACHE_TIMEOUT)
            return output

        return self.compiler.compile_source(source)
Exemplo n.º 2
0
    def render(self, context):
        source = self.nodelist.render(context)

        if USE_CACHE:
            cache_key = get_cache_key("{0}.{1}".format(
                self.__class__.__name__,
                get_hexdigest(source)
            ))
            cache = get_cache()
            cached = cache.get(cache_key, None)
            if cached is not None:
                return cached
            output = self.compiler.compile_source(source)
            cache.set(cache_key, output, CACHE_TIMEOUT)
            return output

        return self.compiler.compile_source(source)
def inlinecompile(nodelist, context, compiler):
    source = nodelist.render(context)

    if isinstance(compiler, six.string_types):
        compiler = utils.get_compiler_by_name(compiler)

    if settings.USE_CACHE:
        cache_key = utils.get_cache_key("{0}.{1}".format(compiler.__class__.__name__, utils.get_hexdigest(source)))
        cache = utils.get_cache()
        cached = cache.get(cache_key, None)
        if cached is not None:
            return cached
        output = compiler.compile_source(source)
        cache.set(cache_key, output, settings.CACHE_TIMEOUT)
        return output

    return compiler.compile_source(source)
Exemplo n.º 4
0
def inlinecompile(nodelist, context, compiler):
    source = nodelist.render(context)

    if isinstance(compiler, six.string_types):
        compiler = utils.get_compiler_by_name(compiler)

    if settings.USE_CACHE:
        cache_key = utils.get_cache_key("{0}.{1}".format(
            compiler.__class__.__name__, utils.get_hexdigest(source)))
        cache = utils.get_cache()
        cached = cache.get(cache_key, None)
        if cached is not None:
            return cached
        output = compiler.compile_source(source)
        cache.set(cache_key, output, settings.CACHE_TIMEOUT)
        return output

    return compiler.compile_source(source)
    def render(self, context):
        source = self.nodelist.render(context)

        if self.compiler[0] == self.compiler[-1] and self.compiler[0] in ('"',
                                                                          "'"):
            compiler = self.compiler[1:-1]
        else:
            compiler = django.template.Variable(self.compiler).resolve(context)

        if isinstance(compiler, six.string_types):
            compiler = utils.get_compiler_by_name(compiler)

        if settings.USE_CACHE:
            cache_key = utils.get_cache_key("{0}.{1}".format(
                compiler.__class__.__name__, utils.get_hexdigest(source)))
            cache = utils.get_cache()
            cached = cache.get(cache_key, None)
            if cached is not None:
                return cached
            output = compiler.compile_source(source)
            cache.set(cache_key, output, settings.CACHE_TIMEOUT)
            return output

        return compiler.compile_source(source)