# HG changeset patch # User Ludovic Chabant # Date 1408462456 25200 # Node ID 923699e816d0f2ac6d30436b2fcb266c8e216634 # Parent df790a827d389bd24ff34205afcfa51222d46961 Don't try to get the name of a source that doesn't have one. TODO: clean up code duplication. diff -r df790a827d38 -r 923699e816d0 piecrust/baking/baker.py --- a/piecrust/baking/baker.py Mon Aug 18 23:20:43 2014 -0700 +++ b/piecrust/baking/baker.py Tue Aug 19 08:34:16 2014 -0700 @@ -165,8 +165,7 @@ has_more_subs = False if ctx.used_pagination is not None: - cur_record_entry.used_source_names.add( - ctx.used_pagination._source.name) + cur_record_entry.addUsedSource(ctx.used_pagination._source) if ctx.used_pagination.has_more: cur_sub += 1 has_more_subs = True diff -r df790a827d38 -r 923699e816d0 piecrust/baking/records.py --- a/piecrust/baking/records.py Mon Aug 18 23:20:43 2014 -0700 +++ b/piecrust/baking/records.py Tue Aug 19 08:34:16 2014 -0700 @@ -1,4 +1,5 @@ import logging +from piecrust.sources.base import PageSource from piecrust.records import Record @@ -52,6 +53,11 @@ return _get_transition_key(self.source_name, self.rel_path, self.taxonomy_name, self.taxonomy_term) + def addUsedSource(self, source): + if isinstance(source, PageSource): + self.used_source_names.add(source.name) + + class TransitionalBakeRecord(object): DELETION_MISSING = 1 DELETION_CHANGED = 2 diff -r df790a827d38 -r 923699e816d0 piecrust/data/provider.py --- a/piecrust/data/provider.py Mon Aug 18 23:20:43 2014 -0700 +++ b/piecrust/data/provider.py Tue Aug 19 08:34:16 2014 -0700 @@ -70,8 +70,7 @@ def _onIteration(self): if not self._ctx_set: eis = self._page.app.env.exec_info_stack - eis.current_page_info.render_ctx.used_source_names.add( - self._source.name) + eis.current_page_info.render_ctx.addUsedSource(self._source.name) self._ctx_set = True @@ -192,8 +191,7 @@ def _onIteration(self): if not self._ctx_set: eis = self._page.app.env.exec_info_stack - eis.current_page_info.render_ctx.used_source_names.add( - self._source.name) + eis.current_page_info.render_ctx.addUsedSource(self._source) self._ctx_set = True diff -r df790a827d38 -r 923699e816d0 piecrust/rendering.py --- a/piecrust/rendering.py Mon Aug 18 23:20:43 2014 -0700 +++ b/piecrust/rendering.py Tue Aug 19 08:34:16 2014 -0700 @@ -4,6 +4,7 @@ from piecrust.data.builder import (DataBuildingContext, build_page_data, build_layout_data) from piecrust.environment import PHASE_PAGE_FORMATTING, PHASE_PAGE_RENDERING +from piecrust.sources.base import PageSource from piecrust.uriutil import get_slug @@ -65,6 +66,10 @@ raise Exception("Pagination has already been used.") self.used_pagination = paginator + def addUsedSource(self, source): + if isinstance(source, PageSource): + self.used_source_names.add(source.name) + def render_page(ctx): eis = ctx.app.env.exec_info_stack