On Friday, June 12, 2015 at 8:36:43 AM UTC-4, zimani wrote: > > I have this code: > > def author(id): > if id is None: > return "Unknown" > else: > user = db.auth_user(id) > me=db(db.auth_user.id == > id).select(db.auth_user.usealiasname).first().usealiasname > if me==False: > return '%(first_name)s %(last_name)s' % user if user else '' > else: > return '%(aliasname)s' % user if user else '' > > > I want to check if the user with a particular 'id' wants to use an > aliasname or real names. However it wont work. i know for sure this line is > the one that is wrong because without the condition it prints properly. can > somebody help. i am sure its simple but i cannot seem to figure it out. > > me=db(db.auth_user.id == > auth.user_id).select(db.auth_user.usealiasname).first().usealiasname >
In the function code you showed above, you have db.auth_user.id == id, but here you have db.auth_user.id == auth.user_id. Which code are you actually using? Is id supposed to be the same value as auth.user_id? If so, your "me" variable is unnecessary, as you are simply fetching the same record that you have already stored in the "user" variable. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.