Mercurial > piecrust2
diff piecrust/sources/posts.py @ 841:f0930178fd01
internal: Make `posts` sources cache their list of pages.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 15 Feb 2017 22:17:54 -0800 |
parents | 58ebf50235a5 |
children | 4850f8c21b6e |
line wrap: on
line diff
--- a/piecrust/sources/posts.py Wed Feb 15 22:17:13 2017 -0800 +++ b/piecrust/sources/posts.py Wed Feb 15 22:17:54 2017 -0800 @@ -22,11 +22,12 @@ PATH_FORMAT = None def __init__(self, app, name, config): - super(PostsSource, self).__init__(app, name, config) + PageSource.__init__(self, app, name, config) self.fs_endpoint = config.get('fs_endpoint', name) self.fs_endpoint_path = os.path.join(self.root_dir, self.fs_endpoint) self.supported_extensions = list(app.config.get('site/auto_formats').keys()) self.default_auto_format = app.config.get('site/default_auto_format') + self._source_it_cache = None @property def path_format(self): @@ -73,7 +74,6 @@ int(m.group(2)), int(m.group(3))) - def findPageFactory(self, metadata, mode): year = metadata.get('year') month = metadata.get('month') @@ -138,6 +138,12 @@ fac_metadata = self._parseMetadataFromPath(rel_path) return PageFactory(self, rel_path, fac_metadata) + def getSourceIterator(self): + if self._source_it_cache is None: + it = SimplePaginationSourceMixin.getSourceIterator(self) + self._source_it_cache = list(it) + return self._source_it_cache + def setupPrepareParser(self, parser, app): parser.add_argument( '-d', '--date', help="The date of the post, "