annotate piecrust/pipelines/page.py @ 903:812ca80863d4

bake: Keep track of which pages were aborted for using other pages.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 23 Jul 2017 08:24:11 -0700
parents b4e10471e970
children abc52a6262a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
1 import logging
852
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2 from piecrust.pipelines.base import ContentPipeline
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
3 from piecrust.pipelines._pagebaker import PageBaker
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
4 from piecrust.pipelines._pagerecords import PagePipelineRecordEntry
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
5 from piecrust.sources.base import AbortedSourceUseError
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
6
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
7
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
8 logger = logging.getLogger(__name__)
852
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
11 class PagePipeline(ContentPipeline):
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12 PIPELINE_NAME = 'page'
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
13 RECORD_ENTRY_CLASS = PagePipelineRecordEntry
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
14
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
15 def __init__(self, source, ppctx):
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
16 super().__init__(source, ppctx)
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
17 self._pagebaker = None
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
18 self._stats = source.app.env.stats
852
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
19
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
20 def initialize(self):
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
21 stats = self.app.env.stats
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
22 stats.registerCounter('SourceUseAbortions', raise_if_registered=False)
903
812ca80863d4 bake: Keep track of which pages were aborted for using other pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 881
diff changeset
23 stats.registerManifest('SourceUseAbortions', raise_if_registered=False)
852
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
25 self._pagebaker = PageBaker(self.app,
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
26 self.ctx.out_dir,
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
27 force=self.ctx.force)
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
28 self._pagebaker.startWriterQueue()
852
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
29
881
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
30 def createJobs(self, ctx):
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
31 used_paths = {}
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
32 for rec in ctx.record_histories.current.records:
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
33 src_name = rec.name.split('@')[0]
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
34 for e in rec.getEntries():
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
35 paths = e.getAllOutputPaths()
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
36 if paths is not None:
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
37 for p in paths:
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
38 used_paths[p] = (src_name, e)
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
39
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
40 jobs = []
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
41 route = self.source.route
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
42 pretty_urls = self.app.config.get('site/pretty_urls')
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
43 record = ctx.record_histories.current.getRecord(self.record_name)
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
44
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
45 for item in self.source.getAllContents():
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
46 route_params = item.metadata['route_params']
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
47 uri = route.getUri(route_params)
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
48 path = self._pagebaker.getOutputPath(uri, pretty_urls)
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
49 override = used_paths.get(path)
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
50 if override is not None:
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
51 override_source_name, override_entry = override
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
52 override_source = self.app.getSource(override_source_name)
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
53 if override_source.config['realm'] == \
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
54 self.source.config['realm']:
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
55 logger.error(
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
56 "Page '%s' would get baked to '%s' "
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
57 "but is overriden by '%s'." %
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
58 (item.spec, path, override_entry.item_spec))
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
59 else:
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
60 logger.debug(
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
61 "Page '%s' would get baked to '%s' "
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
62 "but is overriden by '%s'." %
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
63 (item.spec, path, override_entry.item_spec))
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
64
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
65 entry = PagePipelineRecordEntry()
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
66 entry.item_spec = item.spec
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
67 entry.flags |= PagePipelineRecordEntry.FLAG_OVERRIDEN
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
68 record.addEntry(entry)
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
69
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
70 continue
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
71
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
72 jobs.append(self.createJob(item))
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
73
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
74 if len(jobs) > 0:
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
75 return jobs
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
76 return None
b4e10471e970 bake: Don't create bake jobs for overriden pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 877
diff changeset
77
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
78 def mergeRecordEntry(self, record_entry, ctx):
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
79 existing = ctx.record.getEntry(record_entry.item_spec)
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
80 existing.errors += record_entry.errors
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
81 existing.flags |= record_entry.flags
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
82 existing.subs = record_entry.subs
852
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
83
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
84 def run(self, job, ctx, result):
877
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
85 step_num = job.step_num
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
86 if step_num == 0:
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
87 self._loadPage(job.content_item, ctx, result)
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
88 elif step_num == 1:
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
89 self._renderOrPostpone(job.content_item, ctx, result)
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
90 elif step_num == 2:
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
91 self._renderAlways(job.content_item, ctx, result)
852
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
92
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
93 def getDeletions(self, ctx):
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
94 for prev, cur in ctx.record_history.diffs:
852
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
95 if prev and not cur:
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
96 for sub in prev.subs:
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
97 yield (sub.out_path, 'previous source file was removed')
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
98 elif prev and cur:
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
99 prev_out_paths = [o.out_path for o in prev.subs]
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
100 cur_out_paths = [o.out_path for o in cur.subs]
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
101 diff = set(prev_out_paths) - set(cur_out_paths)
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
102 for p in diff:
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
103 yield (p, 'source file changed outputs')
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
104
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
105 def collapseRecords(self, ctx):
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
106 pass
852
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
107
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
108 def shutdown(self):
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
109 self._pagebaker.stopWriterQueue()
852
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
110
877
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
111 def _loadPage(self, content_item, ctx, result):
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
112 logger.debug("Loading page: %s" % content_item.spec)
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
113 page = self.app.getPage(self.source, content_item)
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
114 record_entry = result.record_entry
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
115 record_entry.config = page.config.getAll()
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
116 record_entry.timestamp = page.datetime.timestamp()
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
117 result.next_step_job = self.createJob(content_item)
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
118
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
119 def _renderOrPostpone(self, content_item, ctx, result):
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
120 # Here our job is to render the page's segments so that they're
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
121 # cached in memory and on disk... unless we detect that the page
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
122 # is using some other sources, in which case we abort and we'll try
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
123 # again on the second pass.
877
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
124 logger.debug("Conditional render for: %s" % content_item.spec)
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
125 page = self.app.getPage(self.source, content_item)
877
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
126 prev_entry = ctx.previous_entry
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
127 cur_entry = result.record_entry
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
128 self.app.env.abort_source_use = True
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
129 try:
877
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
130 self._pagebaker.bake(page, prev_entry, cur_entry)
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
131 except AbortedSourceUseError:
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
132 logger.debug("Page was aborted for using source: %s" %
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
133 content_item.spec)
877
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
134 self.app.env.stats.stepCounter("SourceUseAbortions")
903
812ca80863d4 bake: Keep track of which pages were aborted for using other pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 881
diff changeset
135 self.app.env.stats.addManifestEntry("SourceUseAbortions",
812ca80863d4 bake: Keep track of which pages were aborted for using other pages.
Ludovic Chabant <ludovic@chabant.com>
parents: 881
diff changeset
136 content_item.spec)
877
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
137 result.next_step_job = self.createJob(content_item)
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
138 finally:
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
139 self.app.env.abort_source_use = False
852
4850f8c21b6e core: Start of the big refactor for PieCrust 3.0.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
140
877
d6d35b2efd04 bake: Rename "pass" to "step" and make the page pipeline use different steps.
Ludovic Chabant <ludovic@chabant.com>
parents: 871
diff changeset
141 def _renderAlways(self, content_item, ctx, result):
854
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
142 logger.debug("Full render for: %s" % content_item.spec)
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
143 page = self.app.getPage(self.source, content_item)
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
144 prev_entry = ctx.previous_entry
08e02c2a2a1a core: Keep refactoring, this time to prepare for generator sources.
Ludovic Chabant <ludovic@chabant.com>
parents: 852
diff changeset
145 cur_entry = result.record_entry
871
504ddb370df8 refactor: Fixing some issues with baking assets.
Ludovic Chabant <ludovic@chabant.com>
parents: 854
diff changeset
146 self._pagebaker.bake(page, prev_entry, cur_entry)