Mercurial > piecrust2
comparison 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 |
comparison
equal
deleted
inserted
replaced
875:7169bf42ec60 | 876:d1095774bfcf |
---|---|
82 return [RouteParameter(name, param_type, | 82 return [RouteParameter(name, param_type, |
83 variadic=self.taxonomy.is_multiple)] | 83 variadic=self.taxonomy.is_multiple)] |
84 | 84 |
85 def findContent(self, route_params): | 85 def findContent(self, route_params): |
86 slugified_term = route_params[self.taxonomy.term_name] | 86 slugified_term = route_params[self.taxonomy.term_name] |
87 spec = '_index[%s]' % slugified_term | 87 spec = '_index' |
88 metadata = {'term': slugified_term, | 88 metadata = {'term': slugified_term, |
89 'record_entry_spec': '_index[%s]' % slugified_term, | |
89 'route_params': { | 90 'route_params': { |
90 self.taxonomy.term_name: slugified_term} | 91 self.taxonomy.term_name: slugified_term} |
91 } | 92 } |
92 return ContentItem(spec, metadata) | 93 return ContentItem(spec, metadata) |
93 | 94 |
262 | 263 |
263 def shutdown(self): | 264 def shutdown(self): |
264 self._pagebaker.stopWriterQueue() | 265 self._pagebaker.stopWriterQueue() |
265 | 266 |
266 def createJobs(self, ctx): | 267 def createJobs(self, ctx): |
268 logger.debug("Caching template page for taxonomy '%s'." % | |
269 self.taxonomy.name) | |
270 page = self.app.getPage(self.source, ContentItem('_index', {})) | |
271 page._load() | |
272 | |
267 logger.debug("Building '%s' taxonomy pages for source: %s" % | 273 logger.debug("Building '%s' taxonomy pages for source: %s" % |
268 (self.taxonomy.name, self.inner_source.name)) | 274 (self.taxonomy.name, self.inner_source.name)) |
269 self._analyzer = _TaxonomyTermsAnalyzer(self, ctx.record_histories) | 275 self._analyzer = _TaxonomyTermsAnalyzer(self, ctx.record_histories) |
270 self._analyzer.analyze() | 276 self._analyzer.analyze() |
271 | 277 |
273 (len(self._analyzer.dirty_slugified_terms), | 279 (len(self._analyzer.dirty_slugified_terms), |
274 self.taxonomy.name)) | 280 self.taxonomy.name)) |
275 jobs = [] | 281 jobs = [] |
276 for slugified_term in self._analyzer.dirty_slugified_terms: | 282 for slugified_term in self._analyzer.dirty_slugified_terms: |
277 item = ContentItem( | 283 item = ContentItem( |
278 '_index[%s]' % slugified_term, | 284 '_index', |
279 {'term': slugified_term, | 285 {'term': slugified_term, |
286 'record_entry_spec': '_index[%s]' % slugified_term, | |
280 'route_params': { | 287 'route_params': { |
281 self.taxonomy.term_name: slugified_term} | 288 self.taxonomy.term_name: slugified_term} |
282 }) | 289 }) |
283 jobs.append(self.createJob(item)) | 290 jobs.append(self.createJob(item)) |
284 if len(jobs) > 0: | 291 if len(jobs) > 0: |