Mercurial > piecrust2
comparison piecrust/data/builder.py @ 853:f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
The asset pipeline is still the only function pipeline at this point.
* No more `QualifiedPage`, and several other pieces of code deleted.
* Data providers are simpler and more focused. For instance, the page iterator
doesn't try to support other types of items.
* Route parameters are proper known source metadata to remove the confusion
between the two.
* Make the baker and pipeline more correctly manage records and record
histories.
* Add support for record collapsing and deleting stale outputs in the asset
pipeline.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 21 May 2017 00:06:59 -0700 |
parents | 4850f8c21b6e |
children | 08e02c2a2a1a |
comparison
equal
deleted
inserted
replaced
852:4850f8c21b6e | 853:f070a4fc033c |
---|---|
1 import logging | 1 import logging |
2 from piecrust.data.assetor import Assetor | |
2 from piecrust.data.base import MergedMapping | 3 from piecrust.data.base import MergedMapping |
3 from piecrust.data.linker import PageLinkerData | 4 # from piecrust.data.linker import PageLinkerData |
4 from piecrust.data.pagedata import PageData | 5 from piecrust.data.pagedata import PageData |
5 from piecrust.data.paginator import Paginator | 6 from piecrust.data.paginator import Paginator |
6 from piecrust.data.piecrustdata import PieCrustData | 7 from piecrust.data.piecrustdata import PieCrustData |
7 from piecrust.data.providersdata import DataProvidersData | 8 from piecrust.data.providersdata import DataProvidersData |
8 from piecrust.routing import RouteFunction | 9 from piecrust.routing import RouteFunction |
9 | 10 |
10 | 11 |
11 logger = logging.getLogger(__name__) | 12 logger = logging.getLogger(__name__) |
12 | 13 |
13 | 14 |
14 class DataBuildingContext(object): | 15 class DataBuildingContext: |
15 def __init__(self, qualified_page): | 16 def __init__(self, page, sub_num): |
16 self.qualified_page = qualified_page | 17 self.page = page |
18 self.sub_num = sub_num | |
17 self.pagination_source = None | 19 self.pagination_source = None |
18 self.pagination_filter = None | 20 self.pagination_filter = None |
19 | 21 |
20 | 22 |
21 def build_page_data(ctx): | 23 def build_page_data(ctx): |
22 qpage = ctx.qualified_page | 24 page = ctx.page |
23 page = qpage.page | 25 sub_num = ctx.sub_num |
24 app = page.app | 26 app = page.app |
27 | |
25 pgn_source = ctx.pagination_source or get_default_pagination_source(page) | 28 pgn_source = ctx.pagination_source or get_default_pagination_source(page) |
26 first_uri = ctx.page.getUri(1) | |
27 | 29 |
28 pc_data = PieCrustData() | 30 pc_data = PieCrustData() |
29 config_data = PageData(page, ctx) | 31 config_data = PageData(page, ctx) |
30 paginator = Paginator(qpage, pgn_source, | 32 paginator = Paginator(pgn_source, page, sub_num, |
31 pgn_filter=ctx.pagination_filter) | 33 pgn_filter=ctx.pagination_filter) |
32 assetor = page.source.buildAssetor(page, first_uri) | 34 assetor = Assetor(page) |
33 linker = PageLinkerData(page.source, page.rel_path) | 35 # linker = PageLinkerData(page.source, page.rel_path) |
34 data = { | 36 data = { |
35 'piecrust': pc_data, | 37 'piecrust': pc_data, |
36 'page': config_data, | 38 'page': config_data, |
37 'assets': assetor, | 39 'assets': assetor, |
38 'pagination': paginator, | 40 'pagination': paginator, |
39 'family': linker | 41 # 'family': linker |
40 } | 42 } |
41 | 43 |
42 for route in app.routes: | 44 for route in app.routes: |
43 name = route.func_name | 45 name = route.func_name |
44 if not name: | 46 if not name: |