You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
current_user implement through LocalProxy, while user login , then set the _request_ctx_stack.top.user= login user, i don't understand why we need use current_user._get_current_object() to got the user object.
i always thought current_app._get_current_object or current_user._current_object is used to the request not in the same context, like the example『sendmail.py』, it seem i am wrong.
i am sorry , my english is very poor, hope you can understand what i mean!
The text was updated successfully, but these errors were encountered:
Both are equivalent, but I prefer the former because it uses objects instead of IDs. The reason why you need to add _get_current_object() is that as you stated, current_user is not a User object, it is a proxy object. SQLAlchemy gets confused if you give it the proxy, so you have to retrieve the actual User object from inside the proxy.
I try to understand Flask Web example 11-3 app/main/views.py
but I was thinking about something, why don't use current_user.id?
i try to create a View Function
I got the following result
current_user implement through LocalProxy, while user login , then set the _request_ctx_stack.top.user= login user, i don't understand why we need use current_user._get_current_object() to got the user object.
i always thought current_app._get_current_object or current_user._current_object is used to the request not in the same context, like the example『sendmail.py』, it seem i am wrong.
i am sorry , my english is very poor, hope you can understand what i mean!
The text was updated successfully, but these errors were encountered: