I am using python and Google app engine. I would like to use the task queue. As part of the task queue handler I check if the current user is an admin (using the Users service). This test always fails. Is there a way to cause this test to pass?
update: To avoid further confusion, I am trying to find if the user that triggered the task was an admin or not (this is just a simple example). I understand that the task is being run from the server and all the users cookies are long gone. So the answer I was hopping for was a way to transfer the session to the task
import logging
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import taskqueue
class MyRequesHandler(webapp.RequestHandler):
def get(self):
taskqueue.add(url="/task/")
class MyTaskHandler(webapp.RequestHandler):
def post(self):
if users.is_current_user_admin():
logging.debug("admin")
else:
logging.debug("not admin")
def main():
logging.getLogger().setLevel(logging.DEBUG)
application = webapp.WSGIApplication([
('/', MyRequesHandler),
('/task/', MyTaskHandler)
],
debug=True)
run_wsgi_app(application)