(
self, scope: Scope
)
| 2758 | yield from route.effective_low_priority_routes() |
| 2759 | |
| 2760 | def _match_low_priority( |
| 2761 | self, scope: Scope |
| 2762 | ) -> tuple[Match, Scope, BaseRoute | None, _EffectiveRouteContext | None]: |
| 2763 | full: tuple[Scope, BaseRoute, _EffectiveRouteContext | None] | None = None |
| 2764 | partial: tuple[Scope, BaseRoute, _EffectiveRouteContext | None] | None = None |
| 2765 | for candidate in self._iter_low_priority_routes(): |
| 2766 | route: BaseRoute |
| 2767 | if isinstance(candidate, _EffectiveRouteContext): |
| 2768 | route_context: _EffectiveRouteContext | None = candidate |
| 2769 | original_route = candidate.original_route |
| 2770 | if isinstance(original_route, APIRoute): |
| 2771 | fastapi_scope = _get_fastapi_scope(scope) |
| 2772 | previous_context = fastapi_scope.get( |
| 2773 | _FASTAPI_EFFECTIVE_ROUTE_CONTEXT_KEY, _SCOPE_MISSING |
| 2774 | ) |
| 2775 | fastapi_scope[_FASTAPI_EFFECTIVE_ROUTE_CONTEXT_KEY] = route_context |
| 2776 | try: |
| 2777 | match, child_scope = original_route.matches(scope) |
| 2778 | finally: |
| 2779 | _restore_fastapi_scope_key( |
| 2780 | scope, |
| 2781 | _FASTAPI_EFFECTIVE_ROUTE_CONTEXT_KEY, |
| 2782 | previous_context, |
| 2783 | ) |
| 2784 | route = original_route |
| 2785 | else: |
| 2786 | match, child_scope = candidate.matches(scope) |
| 2787 | route = candidate.starlette_route or original_route |
| 2788 | else: |
| 2789 | route_context = None |
| 2790 | match, child_scope = candidate.matches(scope) |
| 2791 | route = candidate |
| 2792 | if match == Match.FULL: |
| 2793 | if full is None or self._frontend_match_is_more_specific( |
| 2794 | child_scope, full[0] |
| 2795 | ): |
| 2796 | full = (child_scope, route, route_context) |
| 2797 | elif match == Match.PARTIAL: |
| 2798 | if partial is None or self._frontend_match_is_more_specific( |
| 2799 | child_scope, partial[0] |
| 2800 | ): |
| 2801 | partial = (child_scope, route, route_context) |
| 2802 | if full is not None: |
| 2803 | child_scope, route, route_context = full |
| 2804 | return Match.FULL, child_scope, route, route_context |
| 2805 | if partial is not None: |
| 2806 | child_scope, route, route_context = partial |
| 2807 | return Match.PARTIAL, child_scope, route, route_context |
| 2808 | return Match.NONE, {}, None, None |
| 2809 | |
| 2810 | def _frontend_match_is_more_specific( |
| 2811 | self, child_scope: Scope, previous_child_scope: Scope |
no test coverage detected