Re: [pylons-discuss] How to handle unknown resource IDs with URL dispatch and a security policy?

2024-11-21 Thread Sean Hammond
On Thu, 21 Nov 2024, at 6:08 PM, Ian Wilson wrote: > I use a route factory and inside that factory if I can't resolve the context > then I raise HTTPNotFound. The factories let you use context without using > traversal. Aha, I hadn't realised that the factory can raise HTTPNotFound. That works.

Re: [pylons-discuss] How to handle unknown resource IDs with URL dispatch and a security policy?

2024-11-21 Thread Ian Wilson
I use a route factory and inside that factory if I can't resolve the context then I raise HTTPNotFound. The factories let you use context without using traversal. Something like this: def member_factory(request): member = lookup_member(request.matchdict['memberid']) if not member:

[pylons-discuss] How to handle unknown resource IDs with URL dispatch and a security policy?

2024-11-21 Thread Sean Hammond
Hey, I'm wondering what's the best way for a Pyramid app that uses URL dispatch rather than traversal to handle requests that reference resources that don't exist. For example imagine a JSON API request like this, to edit the role of a member in a group: HTTP PATCH /api/groups/{groupid}/m