Created
February 1, 2014 15:34
-
-
Save ntrepid8/8753805 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MessagesHandler(tornado.web.RequestHandler): | |
@tornado.web.asynchronous | |
@tornado.gen.engine | |
def get(self): | |
db = self.settings['db'] | |
rb = [] | |
cursor = db.messages.find().sort([('_id', -1)]) | |
messages = yield motor.Op(cursor.to_list, length=50) | |
while messages: | |
[rb.append({'id': m['_id'], 'msg': m['msg']}) for m in messages] | |
messages = yield motor.Op(cursor.to_list, length=50) | |
self.finish({"data": rb}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment