This makes sense. This was what I was wondering. Thanks for the answer!

On Sun, Aug 4, 2013 at 7:27 PM, Anthony <[email protected]> wrote:

> auth.user is stored in the session and is not refreshed from the database
> on every request, which would be inefficient. Presumably you don't
> typically drop your db tables in production.
>
> Anthony
>
>
> On Sunday, August 4, 2013 4:58:40 PM UTC-4, Mark Finkelstein wrote:
>>
>> Yes, I thought this was so, my issue is more with the fact that after
>> dropping the databases, this seems to give an invalid value, as shown in my
>> first post? I may be wrong.
>>
>> On Sunday, August 4, 2013 3:07:46 PM UTC-4, Anthony wrote:
>>>
>>> If the user is not logged in, auth.user will return None, so you can't
>>> do auth.user.id. Instead, you should use auth.user_id, which will
>>> return None if not logged in.
>>>
>>> Anthony
>>>
>>> On Sunday, August 4, 2013 12:04:16 PM UTC-4, Mark Finkelstein wrote:
>>>>
>>>> I get  the following error for trying that:
>>>> print db.auth_user[auth.user.id]
>>>> AttributeError: 'NoneType' object has no attribute 'id'
>>>>
>>>> I thought `auth.user` is supposed to be used to check if the user is
>>>> logged in?
>>>>
>>>> On Sunday, August 4, 2013 10:35:14 AM UTC-4, Massimo Di Pierro wrote:
>>>>>
>>>>> If you are not logged in db.auth_user[auth.user.id] is None.
>>>>>
>>>>>
>>>>> On Sunday, 4 August 2013 09:10:09 UTC-5, Mark Finkelstein wrote:
>>>>>>
>>>>>> I have two lines of code that read as follows:
>>>>>>
>>>>>> if auth.user:
>>>>>>     if db.auth_user[auth.user.id]['**image']=='' or db.auth_user[auth
>>>>>> .user.id]['**image']==None:
>>>>>>
>>>>>> Recently, while logged in, I dropped all the tables, refreshed the
>>>>>> page and then got an Internal Error saying
>>>>>>
>>>>>>  if db.auth_user[auth.user.id]['**image']=='' or db.auth_user[auth.
>>>>>> user.id]['**image']==None:
>>>>>> TypeError: 'NoneType' object has no attribute '__getitem__'
>>>>>>
>>>>>> I'm guessing it has to do with cookies saving the session, where the
>>>>>> web2py side recognizes what seems to be a session and building auth.user
>>>>>> based off of this, but I'm not quite sure why auth.user is built without 
>>>>>> a
>>>>>> query check of the database? I was wondering why this is?
>>>>>>
>>>>>  --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/GlGgNaNN7ZI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to