Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

current_user = LocalProxy(lambda: _request_ctx_stack.top.user) AttributeError: 'RequestContext' object has no attribute 'user' #15

Closed
lei-cao opened this issue Jun 5, 2012 · 10 comments

Comments

@lei-cao
Copy link

lei-cao commented Jun 5, 2012

I'm using flask 0.8.

def _load_user(self):
        if request.path.startswith(current_app.static_url_path):
            return
      ......

The code here will cause the

current_user = LocalProxy(lambda: _request_ctx_stack.top.user) AttributeError: 'RequestContext' object has no attribute 'user' 

error.

@maelp
Copy link

maelp commented Jun 5, 2012

I have the same issue

@maelp
Copy link

maelp commented Jun 6, 2012

Actually if I use

app = flask.Flask(__name__, static_folder='public', static_url_path='')

I get the error, but if I use

app = flask.Flask(__name__, static_folder='public')

it works, any idea why it is so?

@maxcountryman
Copy link
Owner

This might be fixed now.

@dfrocha
Copy link

dfrocha commented Jul 13, 2012

I'm having the same issue when I combine Flask-Login with Flask-Principal...
Inside the routes (@app.route... current_user) it works well but when I try to set the identity in the @identity_loaded.connect_via(app) method it doesn't find the user in the ctx. I'm using Flask 0.9, Flask-Principal 0.3 and Flask-Login (latest downloaded from GitHub today)

@HeinrichFilter
Copy link

I'm having the same problem as @dfrocha

@maxcountryman
Copy link
Owner

Sorry, we can't directly support Flask-Principal. This seems to be an issue on their end. We haven't had similar reports or been able to reproduce this with just Flask-Login. Closing this.

@shredding
Copy link

I have the same issue but am not using Flask-Principal ...

@chanserv
Copy link

chanserv commented Apr 3, 2013

Problem solved for me:
We have to configure flask-login before flask principal.
This portion of code generate an error

app = Flask(name)
Principal(app)
login_manager = LoginManager()
login_manager.setup_app(app)

But this code work fine for me

app = Flask(name)
login_manager = LoginManager()
login_manager.setup_app(app)
Principal(app)

@maxcountryman
Copy link
Owner

Thanks.

@jacobsvante
Copy link

I also had an error with this without Principal installed. But it turned out I had forgotten to call my configure_extensions method that initializes Flask-Login among others. So yeah, that's why the exception was raised in my case.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants