Frank, the code in db.py gets executed again on the second request. since auth.id_group() returns True the auth.add_group is not called. so you need an else that sets group_id11=auth.id_group()
cfh On Jul 22, 7:56 am, Frank <thethinkbo...@gmail.com> wrote: > I get a problem, after I created a fresh new app,I only add following into > db.py, > if not auth.id_group("Human Resource"): > group_id11=auth.add_group(role="Human Resource", description="can access > the > admin action") > auth.add_permission(group_id11, 'access to manage') > > when I run this app, it seem that it run ok for first time, but if run second > time, I got error as followings, > > Traceback (most recent call last): > File "C:\web2py\gluon\restricted.py", line 178, in restricted > exec ccode in environment > File "C:/web2py/applications/test/models/db.py", line 78, in <module> > auth.add_permission(group_id11, 'access to manage') > NameError: name 'group_id11' is not defined > > I do not understand, group_id11 should get the value in first run, why it lost > in second run. > > please advise,thanks, > > Frank