Permalink
Browse files

had forgotten to check for existance of previous cushion class member…

… on the Handler object. Also, the example left off the @async_yield decorator on the CushionDBMixin prepare(...)
  • Loading branch information...
1 parent c378b31 commit b61d2a6388f6e2e8d3bc0b7278bc1860cd7bdff9 Jeremy Kelley committed Feb 24, 2011
Showing with 7 additions and 6 deletions.
  1. +5 −4 README.md
  2. +2 −2 tornado_addons/cushion.py
View
@@ -65,7 +65,7 @@ Or, you can wrap your methods with async_yield...
@async_yield
def get(self):
somedata = 'xxx'
- fetchdata = yield AsyncHTTPClient.fetch( 'http://over/there',
+ fetchdata = yield AsyncHTTPClient.fetch( 'http://over/there',
callback=self.yield_cb )
# do stuff with fetchdata here
self.write(fetchdata.body if not fetchdata.error else '')
@@ -93,11 +93,12 @@ especially when used in conjunction with async_yield.
class SomeHandler(RequestHandler, CushionDBMixin, AsyncYieldMixin):
+ @async_yield
def prepare(self):
yield self.db_setup('someDB', uri_to_couchdb, self.yield_cb)
- @async_yield
- def get(self):
+ @async_yield
+ def get(self):
x = yield self.db_one('some_key')
- # ... do stuff wth your data in x now
+ # ... do stuff wth your data in x now
@@ -167,7 +167,6 @@ class CushionDBMixin(object):
db_default = ''
cushion = None
-
def db_ignored_cb(self, *a, **ka):
"""
do as much nothing as possible
@@ -177,7 +176,8 @@ def db_ignored_cb(self, *a, **ka):
def db_setup(self, dbname, uri, callback, **kwa):
print "DB_SETUP", dbname, uri, callback, kwa
self.db_default = dbname
- self.cushion = Cushion(uri, io_loop=kwa.get('io_loop'))
+ if not self.cushion:
+ self.cushion = Cushion(uri, io_loop=kwa.get('io_loop'))
self.cushion.open(
dbname,
callback=callback,

0 comments on commit b61d2a6

Please sign in to comment.