-
- books_by_author, orphans, books_by_parent = models.Book.book_list(filter)
- books_nav = SortedDict()
- for tag in books_by_author:
- if books_by_author[tag]:
- books_nav.setdefault(tag.sort_key[0], []).append(tag)
-
+ cached = permanent_cache.get(cache_key)
+ if cached is not None:
+ rendered_nav, rendered_book_list = cached
+ else:
+ books_by_author, orphans, books_by_parent = models.Book.book_list(filter)
+ books_nav = SortedDict()
+ for tag in books_by_author:
+ if books_by_author[tag]:
+ books_nav.setdefault(tag.sort_key[0], []).append(tag)
+ rendered_nav = render_to_string(nav_template_name, locals())
+ rendered_book_list = render_to_string(list_template_name, locals())
+ permanent_cache.set(cache_key, (rendered_nav, rendered_book_list))