Like :meth:`~sqlalchemy.orm.Query.get` but aborts with a ``404 Not Found`` error instead of returning ``None``. :param ident: The primary key to query. :param description: A custom message to show on the error page.
(self, ident: t.Any, description: str | None = None)
| 21 | """ |
| 22 | |
| 23 | def get_or_404(self, ident: t.Any, description: str | None = None) -> t.Any: |
| 24 | """Like :meth:`~sqlalchemy.orm.Query.get` but aborts with a ``404 Not Found`` |
| 25 | error instead of returning ``None``. |
| 26 | |
| 27 | :param ident: The primary key to query. |
| 28 | :param description: A custom message to show on the error page. |
| 29 | """ |
| 30 | rv = self.get(ident) |
| 31 | |
| 32 | if rv is None: |
| 33 | abort(404, description=description) |
| 34 | |
| 35 | return rv |
| 36 | |
| 37 | def first_or_404(self, description: str | None = None) -> t.Any: |
| 38 | """Like :meth:`~sqlalchemy.orm.Query.first` but aborts with a ``404 Not Found`` |
no outgoing calls