diff 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
line wrap: on
line diff
--- a/piecrust/serving/util.py	Sun Oct 29 22:46:41 2017 -0700
+++ b/piecrust/serving/util.py	Sun Oct 29 22:51:57 2017 -0700
@@ -30,9 +30,14 @@
         self.not_found_errors = []
 
 
-def find_routes(routes, uri, uri_no_sub, sub_num=1):
+def find_routes(routes, uri, decomposed_uri=None):
     """ Returns routes matching the given URL.
     """
+    sub_num = 0
+    uri_no_sub = None
+    if decomposed_uri is not None:
+        uri_no_sub, sub_num = decomposed_uri
+
     res = []
     for route in routes:
         route_params = route.matchUri(uri)
@@ -56,7 +61,7 @@
     # It could also be a sub-page (i.e. the URL ends with a page number), so
     # we try to also match the base URL (without the number).
     req_path_no_sub, sub_num = split_sub_uri(app, req_path)
-    routes = find_routes(app.routes, req_path, req_path_no_sub, sub_num)
+    routes = find_routes(app.routes, req_path, (req_path_no_sub, sub_num))
     if len(routes) == 0:
         raise RouteNotFoundError("Can't find route for: %s" % req_path)