So, I have pre-routing for my user module. But now I want to access g.users from other drawings. I found the only way to do this is to copy the code below into each individual project.
I tried putting it in my app.py for @ app.before_request, but then you have errors because you need to import the session, g, User, and then you still get _requestglobal errors in other places.
@app.before_request def before_request(): g.user = None if 'user_id' in session: g.user = User.query.get(session['user_id']);
What is the best place to place it?
I get a lot:
AttributeError: '_RequestGlobals' object has no attribute 'user'
Dexter
source share