Mercurial > piecrust2
diff piecrust/sources/taxonomy.py @ 991:1857dbd4580f
bake: Fix bugs introduced by bake optimizations, of course.
- Make the execution stats JSON-serializable.
- Re-add ability to differentiate between sources used during segment rendering
and during layout rendering. Fixes problems with cache invalidation of
pages that use other sources.
- Make taxonomy-related stuff JSON-serializable.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 20 Nov 2017 23:06:47 -0800 |
parents | 8adc27285d93 |
children | 5f97b5b59dfe |
line wrap: on
line diff
--- a/piecrust/sources/taxonomy.py Sun Nov 19 14:29:52 2017 -0800 +++ b/piecrust/sources/taxonomy.py Mon Nov 20 23:06:47 2017 -0800 @@ -175,15 +175,19 @@ route_val = slugified_values # We need to register this use of a taxonomy term. + # Because the render info gets serialized across bake worker + # processes, we can only use basic JSON-able structures, which + # excludes `set`... hence the awkward use of `list`. + # Also, note that the tuples we're putting in there will be + # transformed into lists so we'll have to convert back. rcs = self.app.env.render_ctx_stack ri = rcs.current_ctx.render_info utt = ri.get('used_taxonomy_terms') if utt is None: - utt = set() - utt.add(slugified_values) - ri['used_taxonomy_terms'] = utt + ri['used_taxonomy_terms'] = [slugified_values] else: - utt.add(slugified_values) + if slugified_values not in utt: + utt.append(slugified_values) # Put the slugified values in the route metadata so they're used to # generate the URL. @@ -481,7 +485,7 @@ pinfo = o['render_info'] terms = pinfo.get('used_taxonomy_terms') if terms: - res |= set(terms) + res |= set([tuple(t) for t in terms]) return res