O'Reilly logo

Flask Framework Cookbook by Shalabh Aggarwal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating user roles

Until now, we saw how a view that is accessible to a certain set of admin users can be created easily using the is_accessible() method. This can be extended to have different kinds of scenarios where specific users will be able to view specific views. There is another way of implementing user roles at a much more granular level in a model where the roles determine whether a user can perform all, some, or any of the CRUD operations.

Getting ready

In this recipe, we will see a basic way of creating user roles, where an admin user can only perform actions they are entitled to.

Note

Remember that this is just one way of implementing user roles. There are many better ways of doing this, but this one seems to be the best one to demonstrate ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required