diff piecrust/sources/taxonomy.py @ 876:d1095774bfcf

refactor: Fix some issues with record/cache entry collisions, add counters.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 15 Jun 2017 07:33:40 -0700
parents 504ddb370df8
children d6d35b2efd04
line wrap: on
line diff
--- a/piecrust/sources/taxonomy.py	Thu Jun 15 07:32:19 2017 -0700
+++ b/piecrust/sources/taxonomy.py	Thu Jun 15 07:33:40 2017 -0700
@@ -84,8 +84,9 @@
 
     def findContent(self, route_params):
         slugified_term = route_params[self.taxonomy.term_name]
-        spec = '_index[%s]' % slugified_term
+        spec = '_index'
         metadata = {'term': slugified_term,
+                    'record_entry_spec': '_index[%s]' % slugified_term,
                     'route_params': {
                         self.taxonomy.term_name: slugified_term}
                     }
@@ -264,6 +265,11 @@
         self._pagebaker.stopWriterQueue()
 
     def createJobs(self, ctx):
+        logger.debug("Caching template page for taxonomy '%s'." %
+                     self.taxonomy.name)
+        page = self.app.getPage(self.source, ContentItem('_index', {}))
+        page._load()
+
         logger.debug("Building '%s' taxonomy pages for source: %s" %
                      (self.taxonomy.name, self.inner_source.name))
         self._analyzer = _TaxonomyTermsAnalyzer(self, ctx.record_histories)
@@ -275,8 +281,9 @@
         jobs = []
         for slugified_term in self._analyzer.dirty_slugified_terms:
             item = ContentItem(
-                '_index[%s]' % slugified_term,
+                '_index',
                 {'term': slugified_term,
+                 'record_entry_spec': '_index[%s]' % slugified_term,
                  'route_params': {
                      self.taxonomy.term_name: slugified_term}
                  })