| 392 | self._compile(method) |
| 393 | |
| 394 | def _compile(self, method): |
| 395 | all_rules = self.dyna_routes[method] |
| 396 | comborules = self.dyna_regexes[method] = [] |
| 397 | maxgroups = self._MAX_GROUPS_PER_PATTERN |
| 398 | for x in range(0, len(all_rules), maxgroups): |
| 399 | some = all_rules[x:x+maxgroups] |
| 400 | combined = (flatpat for (_, flatpat, _, _) in some) |
| 401 | combined = '|'.join('(^%s$)' % flatpat for flatpat in combined) |
| 402 | combined = re.compile(combined).match |
| 403 | rules = [(target, getargs) for (_, _, target, getargs) in some] |
| 404 | comborules.append((combined, rules)) |
| 405 | |
| 406 | def build(self, _name, *anons, **query): |
| 407 | ''' Build an URL by filling the wildcards in a rule. ''' |