Mercurial > piecrust2
comparison piecrust/serving.py @ 334:b034f6f15e22
bake: Several bug taxonomy-related fixes for incorrect incremental bakes.
* Improve how the baker processes taxonomy terms and figures out what needs
to be re-baked or not.
* Create bake entries for clean taxnomy terms so they're not deleted by an
incremental bake.
* Add more information to bake records.
* Slugify taxonomy terms is now done by the route in one place.
* Fix a bug where the cache key for invalidating rendered segments was not
computed the same way as when the caching was done.
* Fix how term combinations are passed around, rendered, printed, parsed, etc.
(TODO: more word needed in the routing functions)
* Expose to the template whether a taxonomy term is a combination or not.
* Display term combinations better in the built-in theme.
* Rename `route.taxonomy` to `route.taxonomy_name` to prevent confusion.
* Add options to show bake records for previous bakes.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 03 Apr 2015 10:59:50 -0700 |
parents | de4903457bed |
children | 938be93215cb |
comparison
equal
deleted
inserted
replaced
333:91b07f9efdc1 | 334:b034f6f15e22 |
---|---|
225 routes = find_routes(app.routes, req_path) | 225 routes = find_routes(app.routes, req_path) |
226 if len(routes) == 0: | 226 if len(routes) == 0: |
227 raise RouteNotFoundError("Can't find route for: %s" % req_path) | 227 raise RouteNotFoundError("Can't find route for: %s" % req_path) |
228 | 228 |
229 taxonomy = None | 229 taxonomy = None |
230 term_value = None | 230 tax_terms = None |
231 for route, route_metadata in routes: | 231 for route, route_metadata in routes: |
232 source = app.getSource(route.source_name) | 232 source = app.getSource(route.source_name) |
233 if route.taxonomy is None: | 233 if route.taxonomy_name is None: |
234 rel_path, fac_metadata = source.findPagePath( | 234 rel_path, fac_metadata = source.findPagePath( |
235 route_metadata, MODE_PARSING) | 235 route_metadata, MODE_PARSING) |
236 if rel_path is not None: | 236 if rel_path is not None: |
237 break | 237 break |
238 else: | 238 else: |
239 taxonomy = app.getTaxonomy(route.taxonomy) | 239 taxonomy = app.getTaxonomy(route.taxonomy_name) |
240 term_value = route_metadata.get(taxonomy.term_name) | 240 route_terms = route_metadata.get(taxonomy.term_name) |
241 if term_value is not None: | 241 if route_terms is not None: |
242 tax_page_ref = taxonomy.getPageRef(source.name) | 242 tax_page_ref = taxonomy.getPageRef(source.name) |
243 rel_path = tax_page_ref.rel_path | 243 rel_path = tax_page_ref.rel_path |
244 source = tax_page_ref.source | 244 source = tax_page_ref.source |
245 fac_metadata = {taxonomy.term_name: term_value} | 245 tax_terms = route.unslugifyTaxonomyTerm(route_terms) |
246 fac_metadata = {taxonomy.term_name: tax_terms} | |
246 break | 247 break |
247 else: | 248 else: |
248 raise SourceNotFoundError( | 249 raise SourceNotFoundError( |
249 "Can't find path for: %s (looked in: %s)" % | 250 "Can't find path for: %s (looked in: %s)" % |
250 (req_path, [r.source_name for r, _ in routes])) | 251 (req_path, [r.source_name for r, _ in routes])) |
255 # We force the rendering of the page because it could not have | 256 # We force the rendering of the page because it could not have |
256 # changed, but include pages that did change. | 257 # changed, but include pages that did change. |
257 render_ctx = PageRenderingContext(page, req_path, page_num, | 258 render_ctx = PageRenderingContext(page, req_path, page_num, |
258 force_render=True) | 259 force_render=True) |
259 if taxonomy is not None: | 260 if taxonomy is not None: |
260 render_ctx.setTaxonomyFilter(taxonomy, term_value) | 261 render_ctx.setTaxonomyFilter(taxonomy, tax_terms) |
261 | 262 |
262 # See if this page is known to use sources. If that's the case, | 263 # See if this page is known to use sources. If that's the case, |
263 # just don't use cached rendered segments for that page (but still | 264 # just don't use cached rendered segments for that page (but still |
264 # use them for pages that are included in it). | 265 # use them for pages that are included in it). |
265 entry = self._page_record.getEntry(req_path, page_num) | 266 entry = self._page_record.getEntry(req_path, page_num) |