So … using the Google App Engine User service.
Should I create a local user object:
my_user = users.get_current_user()
if not my_user:
self.redirect(users.create_login_url(self.request.uri), abort=True)
return
person = Person.get_current(my_user.user_id()) #Here
or access the user object from the users service anytime? :
my_user = users.get_current_user()
if not my_user:
self.redirect(users.create_login_url(self.request.uri), abort=True)
return
#... code ...
person = Person.get_current(users.get_current_user().user_id()) #And here
or something else? :
helping useres :-)
and of course why. Is usage of users service costly in resources?
A locally scoped user object should be fine for each request.
Make sure my_user is local to your thread and the current request:
if it’s shared between separate requests, there’s no guarantee that it’s really the same user issuing the request, unless you have some separate session validation.
different threads can be handling different request, in which case you run into the above problem.