Hi I know this is a common issue for user who is not familiar with async method.... i want to query db with user id using asyncmongo to check if the user log on, but obviously this doesn't work and i don't want to use self.render in call back.
Thanks for your help.
class MainPage(BaseHandler):
def get(self):
if not self.current_user:
#### get no result here
.............
get_current_user function using asyncmongo method:
def get_current_user(self):
user_id = self.get_secure_cookie("user")
if not user_id: return None
self.db.users.find({'user_id': bson.ObjectId(str(user_id))}, limit=1, callback=self._on_response)
def _on_response(self, response, error):
if error:
raise tornado.web.HTTPError(500)
how to return the value of response instead of self.render('template',response) ?