Mercurial > piecrust2
comparison piecrust/sources/autoconfig.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 | 883a5544cd7f |
children | 4850f8c21b6e |
comparison
equal
deleted
inserted
replaced
791:504d6817352d | 792:58ebf50235a5 |
---|---|
1 import re | 1 import re |
2 import os | 2 import os |
3 import os.path | 3 import os.path |
4 import logging | 4 import logging |
5 from piecrust.configuration import ConfigurationError | 5 from piecrust.configuration import ConfigurationError |
6 from piecrust.routing import RouteParameter | |
6 from piecrust.sources.base import ( | 7 from piecrust.sources.base import ( |
7 PageSource, PageFactory, InvalidFileSystemEndpointError) | 8 PageSource, PageFactory, InvalidFileSystemEndpointError) |
8 from piecrust.sources.default import ( | 9 from piecrust.sources.default import ( |
9 filter_page_dirname, filter_page_filename) | 10 filter_page_dirname, filter_page_filename) |
10 from piecrust.sources.interfaces import IListableSource | 11 from piecrust.sources.interfaces import IListableSource |
30 self.capture_mode = config.get('capture_mode', 'path') | 31 self.capture_mode = config.get('capture_mode', 'path') |
31 if self.capture_mode not in ['path', 'dirname', 'filename']: | 32 if self.capture_mode not in ['path', 'dirname', 'filename']: |
32 raise ConfigurationError("Capture mode in source '%s' must be " | 33 raise ConfigurationError("Capture mode in source '%s' must be " |
33 "one of: path, dirname, filename" % | 34 "one of: path, dirname, filename" % |
34 name) | 35 name) |
36 | |
37 def getSupportedRouteParameters(self): | |
38 return [ | |
39 RouteParameter('slug', RouteParameter.TYPE_PATH)] | |
35 | 40 |
36 def buildPageFactories(self): | 41 def buildPageFactories(self): |
37 logger.debug("Scanning for pages in: %s" % self.fs_endpoint_path) | 42 logger.debug("Scanning for pages in: %s" % self.fs_endpoint_path) |
38 if not os.path.isdir(self.fs_endpoint_path): | 43 if not os.path.isdir(self.fs_endpoint_path): |
39 raise InvalidFileSystemEndpointError(self.name, | 44 raise InvalidFileSystemEndpointError(self.name, |