(self)
| 543 | return messages or self.pattern.check() |
| 544 | |
| 545 | def _populate(self): |
| 546 | # Short-circuit if called recursively in this thread to prevent |
| 547 | # infinite recursion. Concurrent threads may call this at the same |
| 548 | # time and will need to continue, so set 'populating' on a |
| 549 | # thread-local variable. |
| 550 | if getattr(self._local, "populating", False): |
| 551 | return |
| 552 | try: |
| 553 | self._local.populating = True |
| 554 | lookups = MultiValueDict() |
| 555 | namespaces = {} |
| 556 | apps = {} |
| 557 | language_code = get_language() |
| 558 | for url_pattern in reversed(self.url_patterns): |
| 559 | p_pattern = url_pattern.pattern.regex.pattern |
| 560 | p_pattern = p_pattern.removeprefix("^") |
| 561 | if isinstance(url_pattern, URLPattern): |
| 562 | self._callback_strs.add(url_pattern.lookup_str) |
| 563 | bits = normalize(url_pattern.pattern.regex.pattern) |
| 564 | lookups.appendlist( |
| 565 | url_pattern.callback, |
| 566 | ( |
| 567 | bits, |
| 568 | p_pattern, |
| 569 | url_pattern.default_args, |
| 570 | url_pattern.pattern.converters, |
| 571 | ), |
| 572 | ) |
| 573 | if url_pattern.name is not None: |
| 574 | lookups.appendlist( |
| 575 | url_pattern.name, |
| 576 | ( |
| 577 | bits, |
| 578 | p_pattern, |
| 579 | url_pattern.default_args, |
| 580 | url_pattern.pattern.converters, |
| 581 | ), |
| 582 | ) |
| 583 | else: # url_pattern is a URLResolver. |
| 584 | url_pattern._populate() |
| 585 | if url_pattern.app_name: |
| 586 | apps.setdefault(url_pattern.app_name, []).append( |
| 587 | url_pattern.namespace |
| 588 | ) |
| 589 | namespaces[url_pattern.namespace] = (p_pattern, url_pattern) |
| 590 | else: |
| 591 | for name in url_pattern.reverse_dict: |
| 592 | for ( |
| 593 | matches, |
| 594 | pat, |
| 595 | defaults, |
| 596 | converters, |
| 597 | ) in url_pattern.reverse_dict.getlist(name): |
| 598 | new_matches = normalize(p_pattern + pat) |
| 599 | lookups.appendlist( |
| 600 | name, |
| 601 | ( |
| 602 | new_matches, |
no test coverage detected