Mercurial > piecrust2
comparison piecrust/pipelines/page.py @ 1020:298b07a899b5
bake: Fix overriding issues between theme and user pages for index pages.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 05 Dec 2017 22:26:25 -0800 |
parents | 3c6e6e7b9639 |
children | d85de09f40c7 |
comparison
equal
deleted
inserted
replaced
1019:bd544b65cfad | 1020:298b07a899b5 |
---|---|
33 self.ctx.out_dir, | 33 self.ctx.out_dir, |
34 force=self.ctx.force) | 34 force=self.ctx.force) |
35 self._pagebaker.startWriterQueue() | 35 self._pagebaker.startWriterQueue() |
36 | 36 |
37 def createJobs(self, ctx): | 37 def createJobs(self, ctx): |
38 if ctx.pass_num == 0: | 38 pass_num = ctx.pass_num |
39 if pass_num == 0: | |
39 return self._createLoadJobs(ctx) | 40 return self._createLoadJobs(ctx) |
40 if ctx.pass_num == 1: | 41 if pass_num == 1: |
41 return self._createSecondPassJobs(ctx) | 42 return self._createSecondPassJobs(ctx) |
42 return self._createThirdPassJobs(ctx) | 43 if pass_num == 2: |
44 return self._createThirdPassJobs(ctx) | |
45 raise Exception("Unexpected pipeline pass: %d" % pass_num) | |
43 | 46 |
44 def _createLoadJobs(self, ctx): | 47 def _createLoadJobs(self, ctx): |
45 # Here we load all the pages in the source, making sure they all | 48 # Here we load all the pages in the source, making sure they all |
46 # have a valid cache for their configuration and contents. | 49 # have a valid cache for their configuration and contents. |
47 jobs = [] | 50 jobs = [] |
75 | 78 |
76 # Skip draft pages. | 79 # Skip draft pages. |
77 if cur.flags & PagePipelineRecordEntry.FLAG_IS_DRAFT: | 80 if cur.flags & PagePipelineRecordEntry.FLAG_IS_DRAFT: |
78 continue | 81 continue |
79 | 82 |
80 # Skip pages that are known to use other sources... we'll | 83 # For pages that are known to use other sources, we make a dummy |
81 # schedule them in the second pass. | 84 # job that will effectively get directly passed on to the next |
85 # step. | |
82 if prev: | 86 if prev: |
83 usn1, usn2 = prev.getAllUsedSourceNames() | 87 usn1, usn2 = prev.getAllUsedSourceNames() |
84 if usn1 or usn2: | 88 if usn1 or usn2: |
89 jobs.append(create_job(self, cur.item_spec, | |
90 pass_num=pass_num, | |
91 uses_sources=True)) | |
85 continue | 92 continue |
86 | 93 |
87 # Check if this item has been overriden by a previous pipeline | 94 # Check if this item has been overriden by a previous pipeline |
88 # run... for instance, we could be the pipeline for a "theme pages" | 95 # run... for instance, we could be the pipeline for a "theme pages" |
89 # source, and some of our pages have been overriden by a user | 96 # source, and some of our pages have been overriden by a user |
165 def handleJobResult(self, result, ctx): | 172 def handleJobResult(self, result, ctx): |
166 pass_num = ctx.pass_num | 173 pass_num = ctx.pass_num |
167 step_num = ctx.step_num | 174 step_num = ctx.step_num |
168 | 175 |
169 if pass_num == 0: | 176 if pass_num == 0: |
177 # Just went through a "load page" job. Let's create a record | |
178 # entry with the information we got from the worker. | |
170 new_entry = self.createRecordEntry(result['item_spec']) | 179 new_entry = self.createRecordEntry(result['item_spec']) |
171 new_entry.flags = result['flags'] | 180 new_entry.flags = result['flags'] |
172 new_entry.config = result['config'] | 181 new_entry.config = result['config'] |
173 new_entry.route_params = result['route_params'] | 182 new_entry.route_params = result['route_params'] |
174 new_entry.timestamp = result['timestamp'] | 183 new_entry.timestamp = result['timestamp'] |
175 ctx.record.addEntry(new_entry) | 184 ctx.record.addEntry(new_entry) |
176 else: | 185 else: |
186 # Update the entry with the new information. | |
177 existing = ctx.record_entry | 187 existing = ctx.record_entry |
178 merge_job_result_into_record_entry(existing, result) | 188 merge_job_result_into_record_entry(existing, result) |
179 | 189 |
180 if existing.was_any_sub_baked: | 190 if existing.was_any_sub_baked: |
181 ctx.record.user_data['dirty_source_names'].add(self.source.name) | 191 ctx.record.user_data['dirty_source_names'].add(self.source.name) |
232 result['flags'] |= PagePipelineRecordEntry.FLAG_SOURCE_MODIFIED | 242 result['flags'] |= PagePipelineRecordEntry.FLAG_SOURCE_MODIFIED |
233 if page.config.get(self._draft_setting): | 243 if page.config.get(self._draft_setting): |
234 result['flags'] |= PagePipelineRecordEntry.FLAG_IS_DRAFT | 244 result['flags'] |= PagePipelineRecordEntry.FLAG_IS_DRAFT |
235 | 245 |
236 def _renderOrPostpone(self, job, ctx, result): | 246 def _renderOrPostpone(self, job, ctx, result): |
247 # See if we should immediately kick this job off to the next step. | |
248 if job.get('uses_sources', False): | |
249 result['next_step_job'] = create_job(self, job['job_spec'][1]) | |
250 return | |
251 | |
237 # Here our job is to render the page's segments so that they're | 252 # Here our job is to render the page's segments so that they're |
238 # cached in memory and on disk... unless we detect that the page | 253 # cached in memory and on disk... unless we detect that the page |
239 # is using some other sources, in which case we abort and we'll try | 254 # is using some other sources, in which case we abort and we'll try |
240 # again on the second pass. | 255 # again on the second pass. |
241 content_item = content_item_from_job(self, job) | 256 content_item = content_item_from_job(self, job) |