Задать вопрос

Тел: +7 965 3737 888

404

Просмотров

2

Ответов

template + cache = crazy delicious

<p>A couple of utility Node subclasses that will automatically cache thier contents. 
</p>
<p>Use CachedNode for template tags that output content into the template:
</p>
class SomeNode(CachedNode):

    def get_cache_key(self, context):
        return "some-cache-key"

    def get_content(self, context):
        return expensive_operation()
<p>Use CachedContextUpdatingNode for tags that update the context:
</p>
class AnotherNode(CachedContextUpdatingNode):

    # Only cache for 60 seconds
    cache_timeout = 60

    def get_cache_key(self, context);
        return "some-other-cache-key"

    def get_content(self, context):
        return {"key" : expensive_operation()}

Вопрос полезен? Да0/Нет0
file_4284.py(1.7Кб)
None

Ответы (2):

Ответubernostrum:10.05.2007
Ответ полезен? Да0/Нет0

This looks familiar... :)

Ответstormlifter:03.01.2011
Ответ полезен? Да0/Нет0

What cache does this use? Doesn't seem to be using the default cache in 1.2.4