Mercurial > piecrust2
comparison piecrust/app.py @ 329:422052d2e978
internal: Try handling URLs in a consistent way.
* Now URLs passed to, and returned from, routes will always be absolute URLs,
i.e. URLs including the site root.
* Validate the site root at config loading time to make sure it starts and ends
with a slash.
* Get rid of unused stuff.
* Add tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 31 Mar 2015 23:03:28 -0700 |
parents | edcc9dc17b37 |
children | b034f6f15e22 |
comparison
equal
deleted
inserted
replaced
328:2a5996e0d3ec | 329:422052d2e978 |
---|---|
26 | 26 |
27 | 27 |
28 logger = logging.getLogger(__name__) | 28 logger = logging.getLogger(__name__) |
29 | 29 |
30 | 30 |
31 CACHE_VERSION = 17 | 31 CACHE_VERSION = 18 |
32 | 32 |
33 | 33 |
34 class VariantNotFoundError(Exception): | 34 class VariantNotFoundError(Exception): |
35 def __init__(self, variant_path, message=None): | 35 def __init__(self, variant_path, message=None): |
36 super(VariantNotFoundError, self).__init__( | 36 super(VariantNotFoundError, self).__init__( |
133 values['site'] = sitec | 133 values['site'] = sitec |
134 | 134 |
135 # Add a section for our cached information. | 135 # Add a section for our cached information. |
136 cachec = collections.OrderedDict() | 136 cachec = collections.OrderedDict() |
137 values['__cache'] = cachec | 137 values['__cache'] = cachec |
138 | |
139 # Make sure the site root starts and ends with a slash. | |
140 if not sitec['root'].startswith('/'): | |
141 raise ConfigurationError("The `site/root` setting must start " | |
142 "with a slash.") | |
143 sitec['root'] = sitec['root'].rstrip('/') + '/' | |
138 | 144 |
139 # Cache auto-format regexes. | 145 # Cache auto-format regexes. |
140 if not isinstance(sitec['auto_formats'], dict): | 146 if not isinstance(sitec['auto_formats'], dict): |
141 raise ConfigurationError("The 'site/auto_formats' setting must be " | 147 raise ConfigurationError("The 'site/auto_formats' setting must be " |
142 "a dictionary.") | 148 "a dictionary.") |