comparison piecrust/baking/single.py @ 711:ab5c6a8ae90a

bake: Replace hard-coded taxonomy support with "generator" system. * Taxonomies are now implemented one or more `TaxonomyGenerator`s. * A `BlogArchivesGenerator` stub is there but non-functional.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 26 May 2016 19:52:47 -0700
parents c62d83e17abf
children 570f89414b2c 10c482d57c79
comparison
equal deleted inserted replaced
710:e85f29b28b84 711:ab5c6a8ae90a
70 bake_path.append(decoded_uri) 70 bake_path.append(decoded_uri)
71 71
72 return os.path.normpath(os.path.join(*bake_path)) 72 return os.path.normpath(os.path.join(*bake_path))
73 73
74 def bake(self, qualified_page, prev_entry, dirty_source_names, 74 def bake(self, qualified_page, prev_entry, dirty_source_names,
75 tax_info=None): 75 generator_name=None):
76 # Start baking the sub-pages. 76 # Start baking the sub-pages.
77 cur_sub = 1 77 cur_sub = 1
78 has_more_subs = True 78 has_more_subs = True
79 sub_entries = [] 79 sub_entries = []
80 80
138 sub_entry.flags |= \ 138 sub_entry.flags |= \
139 SubPageBakeInfo.FLAG_FORMATTING_INVALIDATED 139 SubPageBakeInfo.FLAG_FORMATTING_INVALIDATED
140 140
141 logger.debug(" p%d -> %s" % (cur_sub, out_path)) 141 logger.debug(" p%d -> %s" % (cur_sub, out_path))
142 rp = self._bakeSingle(qualified_page, cur_sub, out_path, 142 rp = self._bakeSingle(qualified_page, cur_sub, out_path,
143 tax_info) 143 generator_name)
144 except Exception as ex: 144 except Exception as ex:
145 logger.exception(ex)
145 page_rel_path = os.path.relpath(qualified_page.path, 146 page_rel_path = os.path.relpath(qualified_page.path,
146 self.app.root_dir) 147 self.app.root_dir)
147 raise BakingError("%s: error baking '%s'." % 148 raise BakingError("%s: error baking '%s'." %
148 (page_rel_path, sub_uri)) from ex 149 (page_rel_path, sub_uri)) from ex
149 150
181 cur_sub += 1 182 cur_sub += 1
182 has_more_subs = True 183 has_more_subs = True
183 184
184 return sub_entries 185 return sub_entries
185 186
186 def _bakeSingle(self, qualified_page, num, out_path, tax_info=None): 187 def _bakeSingle(self, qp, num, out_path,
187 ctx = PageRenderingContext(qualified_page, page_num=num) 188 generator_name=None):
188 if tax_info: 189 ctx = PageRenderingContext(qp, page_num=num)
189 ctx.setTaxonomyFilter(tax_info.term) 190 if qp.route.is_generator_route:
191 qp.route.generator.prepareRenderContext(ctx)
190 192
191 with self.app.env.timerScope("PageRender"): 193 with self.app.env.timerScope("PageRender"):
192 rp = render_page(ctx) 194 rp = render_page(ctx)
193 195
194 with self.app.env.timerScope("PageSerialize"): 196 with self.app.env.timerScope("PageSerialize"):