diff piecrust/app.py @ 363:dd25bd3ce1f9

serve: Refactoring and fixes to be able to serve taxonomy pages. * Page sources' `findPagePath` is renamed to `findPageFactory`, so that it also returns source metadata. * Page refs now store possible hits more properly, and use the previous point to also store metadata. As a result, they can also return a proper factory. * Implement `findPageFactory` correctly in all built-in sources. * When the Chef server matches a taxonomy page, get the source metadata from the page ref in order to make a more proper page. * Make the `getRoute(s)` functions explicitely say if they want taxonomy routes or not.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 26 Apr 2015 15:07:40 -0700
parents ad3e6496f5c3
children 81480d0219ba
line wrap: on
line diff
--- a/piecrust/app.py	Sun Apr 26 08:34:27 2015 -0700
+++ b/piecrust/app.py	Sun Apr 26 15:07:40 2015 -0700
@@ -531,14 +531,15 @@
                 return source
         return None
 
-    def getRoutes(self, source_name, skip_taxonomies=False):
+    def getRoutes(self, source_name, *, skip_taxonomies=False):
         for route in self.routes:
             if route.source_name == source_name:
                 if not skip_taxonomies or route.taxonomy_name is None:
                     yield route
 
-    def getRoute(self, source_name, source_metadata):
-        for route in self.getRoutes(source_name, True):
+    def getRoute(self, source_name, source_metadata, *, skip_taxonomies=False):
+        for route in self.getRoutes(source_name,
+                                    skip_taxonomies=skip_taxonomies):
             if route.matchesMetadata(source_metadata):
                 return route
         return None