comparison piecrust/templating/jinja/extensions.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
comparison
equal deleted inserted replaced
990:22cf13b86cc3 991:1857dbd4580f
144 144
145 def _renderCache(self, name, caller): 145 def _renderCache(self, name, caller):
146 key = self.environment.piecrust_cache_prefix + name 146 key = self.environment.piecrust_cache_prefix + name
147 147
148 rcs = self.environment.app.env.render_ctx_stack 148 rcs = self.environment.app.env.render_ctx_stack
149 ri = rcs.current_ctx.render_info 149 ctx = rcs.current_ctx
150 150
151 # try to load the block from the cache 151 # try to load the block from the cache
152 # if there is no fragment in the cache, render it and store 152 # if there is no fragment in the cache, render it and store
153 # it in the cache. 153 # it in the cache.
154 pair = self.environment.piecrust_cache.get(key) 154 pair = self.environment.piecrust_cache.get(key)
155 if pair is not None: 155 if pair is not None:
156 ri['used_source_names'].update(pair[1]) 156 for usn in pair[1]:
157 ctx.addUsedSource(usn)
157 return pair[0] 158 return pair[0]
158 159
159 prev_used = ri['used_source_names'].copy() 160 prev_used = set(ctx.current_used_source_names)
160 rv = caller() 161 rv = caller()
161 after_used = ri['used_source_names'].copy() 162 after_used = set(ctx.current_used_source_names)
162 used_delta = after_used.difference(prev_used) 163 used_delta = after_used.difference(prev_used)
163 self.environment.piecrust_cache[key] = (rv, used_delta) 164 self.environment.piecrust_cache[key] = (rv, used_delta)
164 return rv 165 return rv
165 166
166 167