I have tables in DB with the same interface for view and edit them with Pyramid app. For example:
Example of route for view record of report table: /birdreport/report/871;
Example of route for edit record of report table: /birdreport/report/871/edit;
Each record of report table has field which contains user_id – this value is the same as returned by authenticated_userid function. It is clear for me how I can disable acces to edit by adding permission to view. But how I can enable access to edit view only for those users which userid presents in corresponding record?
You can use the Pyramid authorization policy by defining
__acl__()inside yourReportmodel. For example:The
__acl__()above will allow everyone to call your viewview, but only the user related toReporttoeditit.It’s likely that you haven’t had authentication policy or authorization policy enabled, to quote the documentation: