Mercurial > piecrust2
diff piecrust/sources/base.py @ 905:1d0364614665
internal: Sources can cache their pages in addition to their items.
Added `getAllPages` to content sources to prevent having to look up cached
page objects in the page repository all the time.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 23 Jul 2017 08:26:57 -0700 |
parents | 504ddb370df8 |
children | 0eca08213354 |
line wrap: on
line diff
--- a/piecrust/sources/base.py Sun Jul 23 08:25:45 2017 -0700 +++ b/piecrust/sources/base.py Sun Jul 23 08:26:57 2017 -0700 @@ -84,6 +84,7 @@ self.name = name self.config = config or {} self._cache = None + self._page_cache = None @property def is_theme_source(self): @@ -99,6 +100,14 @@ def getItemMtime(self, item): raise NotImplementedError() + def getAllPages(self): + if self._page_cache is not None: + return self._page_cache + + getter = self.app.getPage + self._page_cache = [getter(self, i) for i in self.getAllContents()] + return self._page_cache + def getAllContents(self): if self._cache is not None: return self._cache