Like :meth:`~sqlalchemy.orm.Query.one` but aborts with a ``404 Not Found`` error instead of raising ``NoResultFound`` or ``MultipleResultsFound``. :param description: A custom message to show on the error page. .. versionadded:: 3.0
(self, description: str | None = None)
| 48 | return rv |
| 49 | |
| 50 | def one_or_404(self, description: str | None = None) -> t.Any: |
| 51 | """Like :meth:`~sqlalchemy.orm.Query.one` but aborts with a ``404 Not Found`` |
| 52 | error instead of raising ``NoResultFound`` or ``MultipleResultsFound``. |
| 53 | |
| 54 | :param description: A custom message to show on the error page. |
| 55 | |
| 56 | .. versionadded:: 3.0 |
| 57 | """ |
| 58 | try: |
| 59 | return self.one() |
| 60 | except (sa_exc.NoResultFound, sa_exc.MultipleResultsFound): |
| 61 | abort(404, description=description) |
| 62 | |
| 63 | def paginate( |
| 64 | self, |
no outgoing calls