changeset 174:e9a3d405e18f

serve: Always force render the page being previewed. This is because if the page hasn't changed, but it includes pages that did change, it will re-use the cache and the user will preview the old version.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 03 Jan 2015 21:20:19 -0800
parents 0a86a7a6b284
children 7aa5f7880f71
files piecrust/rendering.py piecrust/serving.py
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/rendering.py	Sat Jan 03 21:10:44 2015 -0800
+++ b/piecrust/rendering.py	Sat Jan 03 21:20:19 2015 -0800
@@ -39,10 +39,11 @@
 
 
 class PageRenderingContext(object):
-    def __init__(self, page, uri, page_num=1):
+    def __init__(self, page, uri, page_num=1, force_render=False):
         self.page = page
         self.uri = uri
         self.page_num = page_num
+        self.force_render = force_render
         self.pagination_source = None
         self.pagination_filter = None
         self.custom_data = None
@@ -96,7 +97,7 @@
         # Render content segments.
         ctx.current_pass = PASS_FORMATTING
         repo = ctx.app.env.rendered_segments_repository
-        if repo:
+        if repo and not ctx.force_render:
             cache_key = '%s:%s' % (ctx.uri, ctx.page_num)
             page_time = page.path_mtime
             contents = repo.get(
--- a/piecrust/serving.py	Sat Jan 03 21:10:44 2015 -0800
+++ b/piecrust/serving.py	Sat Jan 03 21:20:19 2015 -0800
@@ -277,7 +277,10 @@
         # Build the page.
         fac = PageFactory(source, rel_path, fac_metadata)
         page = fac.buildPage()
-        render_ctx = PageRenderingContext(page, req_path, page_num)
+        # We force the rendering of the page because it could not have
+        # changed, but include pages that did change.
+        render_ctx = PageRenderingContext(page, req_path, page_num,
+                                          force_render=True)
         if taxonomy is not None:
             flt = PaginationFilter()
             if taxonomy.is_multiple: