comparison piecrust/sources/default.py @ 792:58ebf50235a5

routing: Simplify how routes are defined. * No more declaring the type of route parameters -- the sources and generators already know what type each parameter is supposed to be. * Same for variadic parameters -- we know already. * Update cache version to force a clear reload of the config. * Update tests. TODO: simplify code in the `Route` class to use source or generator transparently.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 07 Sep 2016 08:58:41 -0700
parents ff404adfcf45
children 4850f8c21b6e
comparison
equal deleted inserted replaced
791:504d6817352d 792:58ebf50235a5
1 import os.path 1 import os.path
2 import logging 2 import logging
3 from piecrust import osutil 3 from piecrust import osutil
4 from piecrust.routing import RouteParameter
4 from piecrust.sources.base import ( 5 from piecrust.sources.base import (
5 PageFactory, PageSource, InvalidFileSystemEndpointError, 6 PageFactory, PageSource, InvalidFileSystemEndpointError,
6 MODE_CREATING) 7 MODE_CREATING)
7 from piecrust.sources.interfaces import ( 8 from piecrust.sources.interfaces import (
8 IListableSource, IPreparingSource, IInteractiveSource, 9 IListableSource, IPreparingSource, IInteractiveSource,
33 self.fs_endpoint = config.get('fs_endpoint', name) 34 self.fs_endpoint = config.get('fs_endpoint', name)
34 self.fs_endpoint_path = os.path.join(self.root_dir, self.fs_endpoint) 35 self.fs_endpoint_path = os.path.join(self.root_dir, self.fs_endpoint)
35 self.supported_extensions = list( 36 self.supported_extensions = list(
36 app.config.get('site/auto_formats').keys()) 37 app.config.get('site/auto_formats').keys())
37 self.default_auto_format = app.config.get('site/default_auto_format') 38 self.default_auto_format = app.config.get('site/default_auto_format')
39
40 def getSupportedRouteParameters(self):
41 return [
42 RouteParameter('slug', RouteParameter.TYPE_PATH)]
38 43
39 def buildPageFactories(self): 44 def buildPageFactories(self):
40 logger.debug("Scanning for pages in: %s" % self.fs_endpoint_path) 45 logger.debug("Scanning for pages in: %s" % self.fs_endpoint_path)
41 if not os.path.isdir(self.fs_endpoint_path): 46 if not os.path.isdir(self.fs_endpoint_path):
42 if self.ignore_missing_dir: 47 if self.ignore_missing_dir: