Mercurial > piecrust2
comparison piecrust/templating/jinjaengine.py @ 338:938be93215cb
bake: Improve render context and bake record, fix incremental bake bugs.
* Used sources and taxonomies are now stored on a per-render-pass basis.
This fixes bugs where sources/taxonomies were used for one pass, but that
pass is skipped on a later bake because its result is cached.
* Bake records are now created for all pages even when they're not baked.
Record collapsing is gone except for taxonomy index pages.
* Bake records now also have sub-entries in order to store information about
each sub-page, since some sub-pages could use sources/taxonomies differently
than others, or be missing from the output. This lets PieCrust handle
clean/dirty states on a sub-page level.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 06 Apr 2015 19:59:54 -0700 |
parents | 1ecc0c16ba64 |
children | 498a917cd2d4 |
comparison
equal
deleted
inserted
replaced
337:49408002798e | 338:938be93215cb |
---|---|
384 def _cache_support(self, name, caller): | 384 def _cache_support(self, name, caller): |
385 key = self.environment.piecrust_cache_prefix + name | 385 key = self.environment.piecrust_cache_prefix + name |
386 | 386 |
387 exc_stack = self.environment.app.env.exec_info_stack | 387 exc_stack = self.environment.app.env.exec_info_stack |
388 render_ctx = exc_stack.current_page_info.render_ctx | 388 render_ctx = exc_stack.current_page_info.render_ctx |
389 rdr_pass = render_ctx.current_pass_info | |
389 | 390 |
390 # try to load the block from the cache | 391 # try to load the block from the cache |
391 # if there is no fragment in the cache, render it and store | 392 # if there is no fragment in the cache, render it and store |
392 # it in the cache. | 393 # it in the cache. |
393 pair = self.environment.piecrust_cache.get(key) | 394 pair = self.environment.piecrust_cache.get(key) |
394 if pair is not None: | 395 if pair is not None: |
395 render_ctx.used_source_names.update(pair[1]) | 396 rdr_pass.used_source_names.update(pair[1]) |
396 return pair[0] | 397 return pair[0] |
397 | 398 |
398 with self._lock: | 399 with self._lock: |
399 pair = self.environment.piecrust_cache.get(key) | 400 pair = self.environment.piecrust_cache.get(key) |
400 if pair is not None: | 401 if pair is not None: |
401 render_ctx.used_source_names.update(pair[1]) | 402 rdr_pass.used_source_names.update(pair[1]) |
402 return pair[0] | 403 return pair[0] |
403 | 404 |
404 prev_used = render_ctx.used_source_names.copy() | 405 prev_used = rdr_pass.used_source_names.copy() |
405 rv = caller() | 406 rv = caller() |
406 after_used = render_ctx.used_source_names.copy() | 407 after_used = rdr_pass.used_source_names.copy() |
407 used_delta = after_used.difference(prev_used) | 408 used_delta = after_used.difference(prev_used) |
408 self.environment.piecrust_cache[key] = (rv, used_delta) | 409 self.environment.piecrust_cache[key] = (rv, used_delta) |
409 return rv | 410 return rv |
410 | 411 |
411 | 412 |