()
| 2616 | |
| 2617 | # Sync version |
| 2618 | def router_sync(): |
| 2619 | if self._got_first_request["pages"]: |
| 2620 | return |
| 2621 | self._got_first_request["pages"] = True |
| 2622 | |
| 2623 | inputs = { |
| 2624 | "pathname_": Input(_ID_LOCATION, "pathname"), |
| 2625 | "search_": Input(_ID_LOCATION, "search"), |
| 2626 | } |
| 2627 | inputs.update(self.routing_callback_inputs) |
| 2628 | |
| 2629 | @self.callback( |
| 2630 | Output(_ID_CONTENT, "children"), |
| 2631 | Output(_ID_STORE, "data"), |
| 2632 | inputs=inputs, |
| 2633 | prevent_initial_call=True, |
| 2634 | hidden=True, |
| 2635 | ) |
| 2636 | def update(pathname_, search_, **states): |
| 2637 | query_parameters = _parse_query_string(search_) |
| 2638 | page, path_variables = _path_to_page( |
| 2639 | self.strip_relative_path(pathname_) |
| 2640 | ) |
| 2641 | if page == {}: |
| 2642 | for module, page in _pages.PAGE_REGISTRY.items(): |
| 2643 | if module.split(".")[-1] == "not_found_404": |
| 2644 | layout = page["layout"] |
| 2645 | title = page["title"] |
| 2646 | break |
| 2647 | else: |
| 2648 | layout = html.H1("404 - Page not found") |
| 2649 | title = self.title |
| 2650 | else: |
| 2651 | layout = page.get("layout", "") |
| 2652 | title = page["title"] |
| 2653 | |
| 2654 | if callable(layout): |
| 2655 | layout = layout( |
| 2656 | **{**(path_variables or {}), **query_parameters, **states} |
| 2657 | ) |
| 2658 | if callable(title): |
| 2659 | title = title(**(path_variables or {})) |
| 2660 | return layout, {"title": title} |
| 2661 | |
| 2662 | _validate.check_for_duplicate_pathnames(_pages.PAGE_REGISTRY) |
| 2663 | _validate.validate_registry(_pages.PAGE_REGISTRY) |
| 2664 | |
| 2665 | if not self.config.suppress_callback_exceptions: |
| 2666 | layout = self.layout |
| 2667 | if not isinstance(layout, list): |
| 2668 | # pylint: disable=not-callable |
| 2669 | layout = [self.layout() if callable(self.layout) else self.layout] |
| 2670 | self.validation_layout = html.Div( |
| 2671 | [ |
| 2672 | page["layout"]() if callable(page["layout"]) else page["layout"] |
| 2673 | for page in _pages.PAGE_REGISTRY.values() |
| 2674 | ] |
| 2675 | + layout |
nothing calls this directly
no test coverage detected