Skip to content

Instantly share code, notes, and snippets.

@whardier
Created April 26, 2013 23:21
Show Gist options
  • Save whardier/5471074 to your computer and use it in GitHub Desktop.
Save whardier/5471074 to your computer and use it in GitHub Desktop.
class BaseHandler(tornado.web.RequestHandler):
# ...
@tornado.gen.coroutine
def verify_place_something(self):
motor_db = self.settings['motor_db']
cursor = motor_db.places.find(
# ...
limit = 1,
)
while (yield cursor.fetch_next):
geolocation = cursor.next_object()
raise tornado.gen.Return(geolocation)
class MainHandler(BaseHandler):
@tornado.web.asynchronous
@tornado.gen.coroutine
def get(self):
geolocation = (yield self.verify_place_something())
self.render('index.html')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment