Build an URL by filling the wildcards in a rule.
(self, _name, *anons, **query)
| 389 | return match |
| 390 | |
| 391 | def build(self, _name, *anons, **query): |
| 392 | ''' Build an URL by filling the wildcards in a rule. ''' |
| 393 | builder = self.builder.get(_name) |
| 394 | if not builder: raise RouteBuildError("No route with that name.", _name) |
| 395 | try: |
| 396 | for i, value in enumerate(anons): query['anon%d'%i] = value |
| 397 | url = ''.join([f(query.pop(n)) if n else f for (n,f) in builder]) |
| 398 | return url if not query else url+'?'+urlencode(query) |
| 399 | except KeyError, e: |
| 400 | raise RouteBuildError('Missing URL argument: %r' % e.args[0]) |
| 401 | |
| 402 | def match(self, environ): |
| 403 | ''' Return a (target, url_agrs) tuple or raise HTTPError(400/404/405). ''' |
no test coverage detected