Thank you Anthony, yes I'm aware of that.
I use it like that for this reason: sometimes (not very often) an external 
app modifies a field of the auth_user table (specifically, it sets true or 
false a field that I use as a flag). However that change isn't updated to 
auth.user. In order to do so, the user needs to logout and login again. So 
I retrieve the auth_user record again and store it to response.answer.

Maybe it could be done like this:
if auth.is_logged_in():
    auth.user = db.auth_user[auth.user.id]

But I thought it could be break something with Auth methods, so I store it 
in response.user.

Anyway, I set this topic as "no action needed" because I opened a new 
topic, I've found some more info and I think the issue isn't related to 
that sentence. In fact, if it was related to that sentence, the problem 
would trigger with every user account. Today we just had two more of those 
cases. This is the new topic I posted:
https://groups.google.com/forum/#!topic/web2py/E9jrmf5E-B4

Regards,
Lisandro.


El jueves, 5 de abril de 2018, 12:55:26 (UTC-3), Anthony escribió:
>
> On Tuesday, April 3, 2018 at 8:43:31 AM UTC-4, Lisandro wrote:
>>
>> I store the sessions in the database, so there is no problem with a 
>> locked file.
>>
>> I've just found something interesting that could help to figure out: when 
>> the problem presents, I checked the pg_stat_activity in postgres to see if 
>> there was a long running query, and there is indeed. But the query is a 
>> simple select to the auth_user table, to select the row of the logged in 
>> user. How can this query take that long? Does web2py lock the user row? If 
>> so, how do I release it?
>>
>> Something to consider: in my db.py, at the end, I do this:
>>
>> response.user = db.auth_user[auth.user.id] if auth.is_logged_in() else 
>> None
>>
>
> FYI, auth.user is the user's record from db.auth_user (minus the password 
> field and the update_record and delete_record attributes), so depending on 
> what you are doing with response.user, you might be able to replace the 
> above with:
>
> response.user = auth.user
>
> Or just use auth.user directly in your code.
>
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to