diff piecrust/serving.py @ 298:b7ab1b503510

data: Fix incorrect next/previous page URLs in pagination data. Consolidate splitting an URL between its first URL and its sub page number. Be careful about the index page's URL not losing its slash.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 11 Mar 2015 23:46:42 -0700
parents 8c0c53a315ae
children 65e6d72f3877
line wrap: on
line diff
--- a/piecrust/serving.py	Tue Mar 10 08:34:45 2015 -0700
+++ b/piecrust/serving.py	Wed Mar 11 23:46:42 2015 -0700
@@ -23,6 +23,7 @@
 from piecrust.processing.base import ProcessorPipeline
 from piecrust.rendering import PageRenderingContext, render_page
 from piecrust.sources.base import PageFactory, MODE_PARSING
+from piecrust.uriutil import split_sub_uri
 
 
 logger = logging.getLogger(__name__)
@@ -222,13 +223,7 @@
 
     def _try_serve_page(self, app, environ, request):
         # Try to find what matches the requested URL.
-        req_path = request.path
-        page_num = 1
-        pgn_suffix_re = app.config.get('__cache/pagination_suffix_re')
-        pgn_suffix_m = re.search(pgn_suffix_re, request.path)
-        if pgn_suffix_m:
-            req_path = request.path[:pgn_suffix_m.start()]
-            page_num = int(pgn_suffix_m.group('num'))
+        req_path, page_num = split_sub_uri(app, request.path)
 
         routes = find_routes(app.routes, req_path)
         if len(routes) == 0: