comparison piecrust/sources/base.py @ 369:4b1019bb2533

serve: Giant refactor to change how we handle data when serving pages. * We need a distinction between source metadata and route metadata. In most cases they're the same, but in cases like taxonomy pages, route metadata contains more things that can't be in source metadata if we want to re-use cached pages. * Create a new `QualifiedPage` type which is a page with a specific route and route metadata. Pass this around in many places. * Instead of passing an URL around, use the route in the `QualifiedPage` to generate URLs. This is better since it removes the guess-work from trying to generate URLs for sub-pages. * Deep-copy app and page configurations before passing them around to things that could modify them, like data builders and such. * Exclude taxonomy pages from iterator data providers. * Properly nest iterator data providers for when the theme and user page sources are merged inside `site.pages`.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 03 May 2015 18:47:10 -0700
parents dd25bd3ce1f9
children e7b865f8f335
comparison
equal deleted inserted replaced
368:2408eb6f4da8 369:4b1019bb2533
1 import copy
1 import logging 2 import logging
2 from werkzeug.utils import cached_property 3 from werkzeug.utils import cached_property
3 from piecrust.configuration import ConfigurationError 4 from piecrust.configuration import ConfigurationError
4 from piecrust.page import Page 5 from piecrust.page import Page
5 6
55 return repo.get(cache_key, self._doBuildPage) 56 return repo.get(cache_key, self._doBuildPage)
56 return self._doBuildPage() 57 return self._doBuildPage()
57 58
58 def _doBuildPage(self): 59 def _doBuildPage(self):
59 logger.debug("Building page: %s" % self.path) 60 logger.debug("Building page: %s" % self.path)
60 page = Page(self.source, self.metadata, self.rel_path) 61 page = Page(self.source, copy.deepcopy(self.metadata), self.rel_path)
61 # Load it right away, especially when using the page repository, 62 # Load it right away, especially when using the page repository,
62 # because we'll be inside a critical scope. 63 # because we'll be inside a critical scope.
63 page._load() 64 page._load()
64 return page 65 return page
65 66