Mercurial > piecrust2
comparison piecrust/routing.py @ 396:dc0988d937b3
serve: Fix bug where `?!debug` doesn't get appending correctly.
Add unit test.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 18 May 2015 15:35:52 -0700 |
parents | f33712c4cfab |
children | 21e26ed867b6 |
comparison
equal
deleted
inserted
replaced
395:9e25852f058b | 396:dc0988d937b3 |
---|---|
31 self.source_name = cfg['source'] | 31 self.source_name = cfg['source'] |
32 self.taxonomy_name = cfg.get('taxonomy') | 32 self.taxonomy_name = cfg.get('taxonomy') |
33 | 33 |
34 self.pretty_urls = app.config.get('site/pretty_urls') | 34 self.pretty_urls = app.config.get('site/pretty_urls') |
35 self.trailing_slash = app.config.get('site/trailing_slash') | 35 self.trailing_slash = app.config.get('site/trailing_slash') |
36 self.show_debug_info = app.config.get('site/show_debug_info') | |
36 self.pagination_suffix_format = app.config.get( | 37 self.pagination_suffix_format = app.config.get( |
37 '__cache/pagination_suffix_format') | 38 '__cache/pagination_suffix_format') |
38 self.uri_root = app.config.get('site/root') | 39 self.uri_root = app.config.get('site/root') |
39 | 40 |
40 uri = cfg['url'] | 41 uri = cfg['url'] |
41 self.uri_pattern = uri.lstrip('/') | 42 self.uri_pattern = uri.lstrip('/') |
42 self.uri_format = route_re.sub(self._uriFormatRepl, self.uri_pattern) | 43 self.uri_format = route_re.sub(self._uriFormatRepl, self.uri_pattern) |
43 if app.config.get('site/show_debug_info'): | |
44 self.uri_format += '?!debug' | |
45 | 44 |
46 # Get the straight-forward regex for matching this URI pattern. | 45 # Get the straight-forward regex for matching this URI pattern. |
47 p = route_esc_re.sub(self._uriPatternRepl, | 46 p = route_esc_re.sub(self._uriPatternRepl, |
48 re.escape(self.uri_pattern)) + '$' | 47 re.escape(self.uri_pattern)) + '$' |
49 self.uri_re = re.compile(p) | 48 self.uri_re = re.compile(p) |
169 uri = base_uri + suffix + ext | 168 uri = base_uri + suffix + ext |
170 else: | 169 else: |
171 uri = base_uri + ext | 170 uri = base_uri + ext |
172 | 171 |
173 uri = self.uri_root + uri | 172 uri = self.uri_root + uri |
173 | |
174 if self.show_debug_info: | |
175 uri += '?!debug' | |
176 | |
174 return uri | 177 return uri |
175 | 178 |
176 def slugifyTaxonomyTerm(self, term): | 179 def slugifyTaxonomyTerm(self, term): |
177 #TODO: add options for transliterating and combining terms. | 180 #TODO: add options for transliterating and combining terms. |
178 if isinstance(term, tuple): | 181 if isinstance(term, tuple): |