hi Anthony, i apologise for the late response, i had no access to the 
internet the whole weekend.

Maybe i should clarify. I am customising this from one of your tutorials 
"Web development with python and web2py " part 1 and 2
The 'user' in this case is the person that posted a post. Hence if i use 
auth.user it makes all posts be written by the currently logged in user.
I guess my challenge is extracting the value of 'usealiasname' If its true 
or not for that user that posted. i tried the 'user.usealiasname' but it 
says that user has no attribute 'usealiasname'
But thank you for all the help.


On Friday, 12 June 2015 17:55:03 UTC+2, Anthony wrote:
>
> If you have:
>
> user = db.auth_user(id)
>
> Then there is no need for the "me" variable -- just use user.usealiasname. 
> However, if id is the same as auth.user_id, then you don't even need the 
> above line -- just use auth.user (which holds the whole user record). If it 
> still isn't working, then there is likely a problem elsewhere in your code.
>
> Anthony
>
> On Friday, June 12, 2015 at 9:20:00 AM UTC-4, zimani wrote:
>>
>> Its supposed to be the same. But this does not work. All i am doing is 
>> checking if this user: db.auth_user(id) wants to use an aliasname or not. 
>> Of which aliasname is a field in auth_user table
>>
>> On Friday, 12 June 2015 15:11:19 UTC+2, zimani wrote:
>>>
>>> I apologise, i have been trying too many things:
>>>
>>>
>>> me=db(db.auth_user.id == 
>>> id).select(db.auth_user.usealiasname).first().usealiasname
>>>
>>> This is what i currently have.
>>>
>>>
>>> On Friday, 12 June 2015 14:54:57 UTC+2, Anthony wrote:
>>>>
>>>>
>>>>
>>>> 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.

Reply via email to