diff 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
line wrap: on
line diff
--- a/piecrust/serving.py	Fri Apr 03 08:44:21 2015 -0700
+++ b/piecrust/serving.py	Fri Apr 03 10:59:50 2015 -0700
@@ -227,22 +227,23 @@
             raise RouteNotFoundError("Can't find route for: %s" % req_path)
 
         taxonomy = None
-        term_value = None
+        tax_terms = None
         for route, route_metadata in routes:
             source = app.getSource(route.source_name)
-            if route.taxonomy is None:
+            if route.taxonomy_name is None:
                 rel_path, fac_metadata = source.findPagePath(
                         route_metadata, MODE_PARSING)
                 if rel_path is not None:
                     break
             else:
-                taxonomy = app.getTaxonomy(route.taxonomy)
-                term_value = route_metadata.get(taxonomy.term_name)
-                if term_value is not None:
+                taxonomy = app.getTaxonomy(route.taxonomy_name)
+                route_terms = route_metadata.get(taxonomy.term_name)
+                if route_terms is not None:
                     tax_page_ref = taxonomy.getPageRef(source.name)
                     rel_path = tax_page_ref.rel_path
                     source = tax_page_ref.source
-                    fac_metadata = {taxonomy.term_name: term_value}
+                    tax_terms = route.unslugifyTaxonomyTerm(route_terms)
+                    fac_metadata = {taxonomy.term_name: tax_terms}
                     break
         else:
             raise SourceNotFoundError(
@@ -257,7 +258,7 @@
         render_ctx = PageRenderingContext(page, req_path, page_num,
                                           force_render=True)
         if taxonomy is not None:
-            render_ctx.setTaxonomyFilter(taxonomy, term_value)
+            render_ctx.setTaxonomyFilter(taxonomy, tax_terms)
 
         # See if this page is known to use sources. If that's the case,
         # just don't use cached rendered segments for that page (but still