Mercurial > piecrust2
comparison piecrust/serving/util.py @ 979:45ad976712ec
tests: Big push to get the tests to pass again.
- Lots of fixes everywhere in the code.
- Try to handle debug logging in the multiprocessing worker pool when running in pytest. Not perfect, but usable for now.
- Replace all `.md` test files with `.html` since now a auto-format extension always sets the format.
- Replace `out` with `outfiles` in most places since now blog archives are added to the bake output and I don't want to add expected outputs for blog archives everywhere.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 29 Oct 2017 22:51:57 -0700 |
parents | 84ce51430346 |
children | 8adc27285d93 |
comparison
equal
deleted
inserted
replaced
978:7e51d14097cb | 979:45ad976712ec |
---|---|
28 self.sub_num = 1 | 28 self.sub_num = 1 |
29 self.req_path = None | 29 self.req_path = None |
30 self.not_found_errors = [] | 30 self.not_found_errors = [] |
31 | 31 |
32 | 32 |
33 def find_routes(routes, uri, uri_no_sub, sub_num=1): | 33 def find_routes(routes, uri, decomposed_uri=None): |
34 """ Returns routes matching the given URL. | 34 """ Returns routes matching the given URL. |
35 """ | 35 """ |
36 sub_num = 0 | |
37 uri_no_sub = None | |
38 if decomposed_uri is not None: | |
39 uri_no_sub, sub_num = decomposed_uri | |
40 | |
36 res = [] | 41 res = [] |
37 for route in routes: | 42 for route in routes: |
38 route_params = route.matchUri(uri) | 43 route_params = route.matchUri(uri) |
39 if route_params is not None: | 44 if route_params is not None: |
40 res.append((route, route_params, 1)) | 45 res.append((route, route_params, 1)) |
54 | 59 |
55 # Try to find what matches the requested URL. | 60 # Try to find what matches the requested URL. |
56 # It could also be a sub-page (i.e. the URL ends with a page number), so | 61 # It could also be a sub-page (i.e. the URL ends with a page number), so |
57 # we try to also match the base URL (without the number). | 62 # we try to also match the base URL (without the number). |
58 req_path_no_sub, sub_num = split_sub_uri(app, req_path) | 63 req_path_no_sub, sub_num = split_sub_uri(app, req_path) |
59 routes = find_routes(app.routes, req_path, req_path_no_sub, sub_num) | 64 routes = find_routes(app.routes, req_path, (req_path_no_sub, sub_num)) |
60 if len(routes) == 0: | 65 if len(routes) == 0: |
61 raise RouteNotFoundError("Can't find route for: %s" % req_path) | 66 raise RouteNotFoundError("Can't find route for: %s" % req_path) |
62 | 67 |
63 req_page = RequestedPage() | 68 req_page = RequestedPage() |
64 for route, route_params, route_sub_num in routes: | 69 for route, route_params, route_sub_num in routes: |