You might be looking for something like view derivers https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/hooks.html#custom-view-derivers
That will allow you to accept additional parameters in `add_view`/`@view_config` and wrap the view in customer behavior, such as raising an HTTPForbidden if a certain condition isn’t met. e.g. `permission` is implemented using a view deriver https://github.com/Pylons/pyramid/blob/eb0e01a0fd7aff84c345b1c43bd4fa9d2fe04441/src/pyramid/viewderivers.py#L286-L333 — Theron > On Feb 13, 2025, at 2:22 PM, Thierry Florac <[email protected]> wrote: > > Hi, > I'm building a REST API using Pyramid and Cornice for which I defined custom > view predicates. By default, an HTTP NotFound error is raised when a > predicate is not verified. Is there a way to raise a custom error, like an > HTTP Unauthorized or HTTP Forbidden? > > Best regards, > Thierry > -- > https://www.ulthar.net <https://www.ulthar.net/> -- > http://pyams.readthedocs.io <http://pyams.readthedocs.io/> > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion visit > https://groups.google.com/d/msgid/pylons-discuss/CAPX_VWAa46kYQZeh3-vsS5xB2XCrdL_P73xOew8xf-AgoefrNw%40mail.gmail.com > > <https://groups.google.com/d/msgid/pylons-discuss/CAPX_VWAa46kYQZeh3-vsS5xB2XCrdL_P73xOew8xf-AgoefrNw%40mail.gmail.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/pylons-discuss/4612BE66-D7F2-49FA-8B74-9FAC908097A1%40luhn.com.
