Mercurial > piecrust2
comparison piecrust/serving.py @ 173:0a86a7a6b284
routes: Actually match metadata when finding routes, fix problems with paths.
When we look for a route that matches a given page, we now look at the
source metadata that comes with that page, and compare it to the metadata
we need to build URIs.
Also, when matching URIs, we handle the case where a 'path'-component in
our pattern may be completely empty, and thus we may be missing some trailing
slashes in the URI.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 03 Jan 2015 21:10:44 -0800 |
parents | 70b86e904b85 |
children | e9a3d405e18f |
comparison
equal
deleted
inserted
replaced
172:4fc1d306046b | 173:0a86a7a6b284 |
---|---|
413 | 413 |
414 def find_routes(routes, uri): | 414 def find_routes(routes, uri): |
415 uri = uri.lstrip('/') | 415 uri = uri.lstrip('/') |
416 res = [] | 416 res = [] |
417 for route in routes: | 417 for route in routes: |
418 m = route.uri_re.match(uri) | 418 m = route.matchUri(uri) |
419 if m: | 419 if m: |
420 metadata = m.groupdict() | 420 metadata = m.groupdict() |
421 res.append((route, metadata)) | 421 res.append((route, metadata)) |
422 return res | 422 return res |
423 | 423 |