Mercurial > piecrust2
changeset 23:923699e816d0
Don't try to get the name of a source that doesn't have one.
TODO: clean up code duplication.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 19 Aug 2014 08:34:16 -0700 |
parents | df790a827d38 |
children | 644869022b6e |
files | piecrust/baking/baker.py piecrust/baking/records.py piecrust/data/provider.py piecrust/rendering.py |
diffstat | 4 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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
--- 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
--- 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