From de66e7f40fb19791090ab051e2254fa55c543a09 Mon Sep 17 00:00:00 2001 From: "mission.liao" Date: Thu, 16 Oct 2014 17:44:54 +0800 Subject: [PATCH] this example didn't work actually The way to bind RequestHandler is changed. --- examples/tornado/app.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/examples/tornado/app.py b/examples/tornado/app.py index 0081dc8..52436b7 100644 --- a/examples/tornado/app.py +++ b/examples/tornado/app.py @@ -2,9 +2,22 @@ from tornado import web, gen from restless.tnd import TornadoResource -class PetResource(TornadoResource): + +class BaseHandler(web.RequestHandler): + def prepare(self): - self.fake_db = { + """ do normal tornado preparation """ + + def initialize(self): + """ do your tornado initialization """ + +class PetResource(TornadoResource): + + # bind BaseHandler instead of tornado.web.RequestHandler + _request_handler_base_ = BaseHandler + + def __init__(self): + self.fake_db = [ { "id": 1, "name": "Mitti", @@ -15,7 +28,8 @@ def prepare(self): "name": "Gary", "type": "cat" } - } + ] + @gen.coroutine def list(self):