Mercurial > piecrust2
diff piecrust/serving/util.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 |
line wrap: on
line diff
--- a/piecrust/serving/util.py Wed May 17 00:11:48 2017 -0700 +++ b/piecrust/serving/util.py Sun May 21 00:06:59 2017 -0700 @@ -5,7 +5,7 @@ import datetime from werkzeug.wrappers import Response from werkzeug.wsgi import wrap_file -from piecrust.page import QualifiedPage, PageNotFoundError +from piecrust.page import PageNotFoundError from piecrust.routing import RouteNotFoundError from piecrust.uriutil import split_sub_uri @@ -22,7 +22,8 @@ class RequestedPage(object): def __init__(self): - self.qualified_page = None + self.page = None + self.sub_num = 1 self.req_path = None self.not_found_errors = [] @@ -62,10 +63,11 @@ if route_sub_num > 1: cur_req_path = req_path_no_num - qp = _get_requested_page_for_route(app, route, route_params, - route_sub_num) - if qp is not None: - req_page.qualified_page = qp + page = _get_requested_page_for_route(app, route, route_params, + route_sub_num) + if page is not None: + req_page.page = page + req_page.sub_num = route_sub_num req_page.req_path = cur_req_path break @@ -76,16 +78,12 @@ return req_page -def _get_requested_page_for_route(app, route, route_params, sub_num): +def _get_requested_page_for_route(app, route, route_params): source = app.getSource(route.source_name) item = source.findContent(route_params) - if item is None: - return None - - # Build the page. - page = app.getPage(item) - qp = QualifiedPage(page, route, route_params, sub_num) - return qp + if item is not None: + return app.getPage(item) + return None def load_mimetype_map():