Mercurial > piecrust2
comparison piecrust/serving.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 | c2ca72fb7f0b |
comparison
equal
deleted
inserted
replaced
368:2408eb6f4da8 | 369:4b1019bb2533 |
---|---|
16 from werkzeug.wsgi import ClosingIterator, wrap_file | 16 from werkzeug.wsgi import ClosingIterator, wrap_file |
17 from jinja2 import FileSystemLoader, Environment | 17 from jinja2 import FileSystemLoader, Environment |
18 from piecrust.app import PieCrust | 18 from piecrust.app import PieCrust |
19 from piecrust.environment import StandardEnvironment | 19 from piecrust.environment import StandardEnvironment |
20 from piecrust.processing.base import ProcessorPipeline | 20 from piecrust.processing.base import ProcessorPipeline |
21 from piecrust.rendering import PageRenderingContext, render_page | 21 from piecrust.rendering import QualifiedPage, PageRenderingContext, render_page |
22 from piecrust.sources.base import PageFactory, MODE_PARSING | 22 from piecrust.sources.base import PageFactory, MODE_PARSING |
23 from piecrust.uriutil import split_sub_uri | 23 from piecrust.uriutil import split_sub_uri |
24 | 24 |
25 | 25 |
26 logger = logging.getLogger(__name__) | 26 logger = logging.getLogger(__name__) |
250 | 250 |
251 # Build the page. | 251 # Build the page. |
252 page = factory.buildPage() | 252 page = factory.buildPage() |
253 # We force the rendering of the page because it could not have | 253 # We force the rendering of the page because it could not have |
254 # changed, but include pages that did change. | 254 # changed, but include pages that did change. |
255 render_ctx = PageRenderingContext(page, req_path, page_num, | 255 qp = QualifiedPage(page, route, route_metadata) |
256 render_ctx = PageRenderingContext(qp, | |
257 page_num=page_num, | |
256 force_render=True) | 258 force_render=True) |
257 if taxonomy is not None: | 259 if taxonomy is not None: |
258 render_ctx.setTaxonomyFilter(taxonomy, tax_terms) | 260 render_ctx.setTaxonomyFilter(taxonomy, tax_terms) |
259 | 261 |
260 # See if this page is known to use sources. If that's the case, | 262 # See if this page is known to use sources. If that's the case, |