MdaG
MdaG

Reputation: 2730

How do I hande users when running Google AppEngine on localhost?

In the following code, user is alway None when running on localhost. I assume that there's a way to preload with data, but I can't figure out how.

from google.appengine.api import users
user = users.get_current_user()

What's the "correct" way to handle users when running on localhost?

Upvotes: 0

Views: 64

Answers (2)

Lipis
Lipis

Reputation: 21835

You can always login with the virtual user on localhost through this address http://localhost:8080/_ah/login (if you are running on default 8080 port).

But usually you would redirect your users to a login page using the users.create_login_url() and it will handle it correctly on localhost and on production.

Upvotes: 1

Daniel Roseman
Daniel Roseman

Reputation: 599610

You shouldn't need to do anything special, and get_current_user should not always be None.

Are you sure you're actually logging in a user? You may need to set your handler in app.yaml to login: required to redirect the user to a login form.

Upvotes: 1

Related Questions