pythonpython-3.xpython-2.7web2pyweb2py-modules

Web2py - how to create a group "manager" using appadmin


I'm going through Web2py book documentation because i'm new to it and i can't find any better tutorial anywhere (recommendations are welcomed). While going through the overview section, i got to an instruction that says

Using appadmin create a group "manager" and make some users members of the group.

I've been trying to figure out how to do this for the past few hours and still no success. I can't find any interface in the app admin for creating groups. I tried this plugin manager for managing groups and i was still getting errors. All suggestions are welcomed


Solution

  • See the Authorization section of the Access Control chapter -- as noted there, you can use the appadmin interface (described here) or add groups and members programmatically.

    To access appadmin, just go to /yourapp/appadmin (if you are not logged into the /admin app, you will be prompted to do so).

    To add a new Auth group/role, add a new record to the db.auth_group table in appadmin. To add a new member to that group, add a new record to db.auth_membership, which links records from db.auth_user and db.auth_group.

    You can also add groups and members programmatically, either via app code or a web2py shell (which can be started via python web2py.py -S yourapp -M, as described here). Add groups with auth.add_group and members with auth.add_membership (as documented at the link above).