Your original problem was that this: Field('lab', db.auth_group, label='Lab Name', represent=lambda id,row: str(row.role)+' Lab', default=db.auth_group(current.auth.user_id) ), Field('member',db.auth_user'), )
should have been Field('lab', db.auth_group, label='Lab Name', represent=lambda id,row: str(row.role)+' Lab', default=current.auth.user_id), Field('member',db.auth_user'), ) The default value of a reference field bust be None or the id if a referenced record, not the record itself. Sorry for not catching this before. On Wednesday, 12 December 2012 06:04:48 UTC-6, Kostas M wrote: > > Massimo thank you for your response. > Unfortunately, I have not the traceback now, since I chose to build a > separate table, not referring to db.auth_group. This > is a kind of duplication in regards to auth_group, but it makes simple the > handling of my lab_members table: > > db.define_table('lab_members', > Field('lab',label='Lab Name', > default= auth.user_id and auth.user.username, > writable=False, > ), > Field('member',unique=True,requires=IS_NOT_EMPTY()), > ) > > The strange thing in this case again, is the : > default= auth.user_id and auth.user.username, > which I have taken from an older answer of yours: > > > https://groups.google.com/forum/?fromgroups=#!searchin/web2py/Re:$20Record$20Versioning/web2py/e55el7q_-kk/XkG1hN5w9VYJ > > If i run my application on -S appname mode, having just: "default= > auth.user.username,", this error comes back: > Traceback (most recent call last): > File "/home/kmouts/web2py/gluon/restricted.py", line 212, in restricted > exec ccode in environment > File "applications/lims/models/db.py", line 140, in <module> > default= auth.user.username, > AttributeError: 'NoneType' object has no attribute 'username' > > So it seems a check has to be made first if a current user exists (by > auth.user_id )and then to try to get the attribute username from auth.user. > > --