diff piecrust/baking/worker.py @ 853:f070a4fc033c

core: Continue PieCrust3 refactor, simplify pages. The asset pipeline is still the only function pipeline at this point. * No more `QualifiedPage`, and several other pieces of code deleted. * Data providers are simpler and more focused. For instance, the page iterator doesn't try to support other types of items. * Route parameters are proper known source metadata to remove the confusion between the two. * Make the baker and pipeline more correctly manage records and record histories. * Add support for record collapsing and deleting stale outputs in the asset pipeline.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 21 May 2017 00:06:59 -0700
parents 4850f8c21b6e
children 08e02c2a2a1a
line wrap: on
line diff
--- a/piecrust/baking/worker.py	Wed May 17 00:11:48 2017 -0700
+++ b/piecrust/baking/worker.py	Sun May 21 00:06:59 2017 -0700
@@ -2,7 +2,7 @@
 import logging
 from piecrust.pipelines.base import PipelineContext, PipelineResult
 from piecrust.pipelines.records import (
-    MultiRecordHistory, MultiRecord, Record, load_records)
+    MultiRecordHistory, MultiRecord, RecordEntry, load_records)
 from piecrust.sources.base import ContentItem
 from piecrust.workerpool import IWorker
 
@@ -42,17 +42,6 @@
         stats = app.env.stats
         stats.registerTimer("BakeWorker_%d_Total" % self.wid)
         stats.registerTimer("BakeWorkerInit")
-        stats.registerTimer("JobReceive")
-        stats.registerTimer('LoadJob', raise_if_registered=False)
-        stats.registerTimer('RenderFirstSubJob',
-                            raise_if_registered=False)
-        stats.registerTimer('BakeJob', raise_if_registered=False)
-
-        stats.registerCounter("SourceUseAbortions")
-
-        stats.registerManifest("LoadJobs")
-        stats.registerManifest("RenderJobs")
-        stats.registerManifest("BakeJobs")
 
         self.app = app
 
@@ -90,9 +79,12 @@
         src, pp = self._sources[job.source_name]
         item = ContentItem(job.item_spec, job.item_metadata)
 
-        record_class = pp.RECORD_CLASS or Record
-        ppres = PipelineResult(record_class())
-        ppres.record.item_spec = job.item_spec
+        entry_class = pp.RECORD_ENTRY_CLASS or RecordEntry
+        ppres = PipelineResult()
+        ppres.pipeline_name = pp.PIPELINE_NAME
+        ppres.record_entry = entry_class()
+        ppres.record_entry.item_spec = job.item_spec
+
         pp.run(item, self._ppctx, ppres)
         return ppres
 
@@ -113,26 +105,3 @@
         self.item_spec = item_spec
         self.item_metadata = item_metadata
 
-
-class JobHandler:
-    def __init__(self, ctx):
-        self.ctx = ctx
-
-    @property
-    def app(self):
-        return self.ctx.app
-
-    def handleJob(self, job):
-        raise NotImplementedError()
-
-    def shutdown(self):
-        pass
-
-
-def _get_errors(ex):
-    errors = []
-    while ex is not None:
-        errors.append(str(ex))
-        ex = ex.__cause__
-    return errors
-