Skip to content

Commit

Permalink
Merge pull request #57 from JunAishima/update-tornado
Browse files Browse the repository at this point in the history
Update tornado
  • Loading branch information
JunAishima authored Jan 21, 2022
2 parents 00354af + dc16128 commit fcc6e34
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
27 changes: 14 additions & 13 deletions amostra/server/engine.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from tornado import gen
import tornado.web
import pymongo
import jsonschema
Expand Down Expand Up @@ -80,7 +81,7 @@ class DefaultHandler(tornado.web.RequestHandler):
If you use multiple threads it is important to use IOLoop.add_callback
to transfer control back to the main thread before finishing the request.
"""
@tornado.web.asynchronous
@gen.coroutine
def set_default_headers(self):
self.set_header('Access-Control-Allow-Origin', '*')
self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS')
Expand Down Expand Up @@ -113,7 +114,7 @@ class SampleReferenceHandler(DefaultHandler):
field. Otherwise, provide a dict that holds the new value and field name.
Returns the total number of documents that are updated.
"""
@tornado.web.asynchronous
@gen.coroutine
def get(self):
database = self.settings['db']
query = utils.unpack_params(self)
Expand All @@ -137,7 +138,7 @@ def get(self):
else:
raise compose_err_msg(500, 'No results found!')

@tornado.web.asynchronous
@gen.coroutine
def post(self):
database = self.settings['db']
data = ujson.loads(self.request.body.decode("utf-8"))
Expand Down Expand Up @@ -170,7 +171,7 @@ def post(self):
'SampleHandler expects list or dict')
self.finish(ujson.dumps(uids))

@tornado.web.asynchronous
@gen.coroutine
def put(self):
database = self.settings['db']
incoming = ujson.loads(self.request.body)
Expand All @@ -190,7 +191,7 @@ def put(self):


class RequestReferenceHandler(DefaultHandler):
@tornado.web.asynchronous
@gen.coroutine
def get(self):
database = self.settings['db']
query = utils.unpack_params(self)
Expand All @@ -214,7 +215,7 @@ def get(self):
else:
raise utils._compose_err_msg(500, 'No results found!')

@tornado.web.asynchronous
@gen.coroutine
def post(self):
database = self.settings['db']
data = ujson.loads(self.request.body.decode("utf-8"))
Expand Down Expand Up @@ -257,7 +258,7 @@ def post(self):
status='SampleHandler expects list or dict')
self.finish(ujson.dumps(uids))

@tornado.web.asynchronous
@gen.coroutine
def put(self):
database = self.settings['db']
incoming = ujson.loads(self.request.body)
Expand Down Expand Up @@ -296,7 +297,7 @@ class ContainerReferenceHandler(DefaultHandler):
field. Otherwise, provide a dict that holds the new value and field name.
Returns the total number of documents that are updated.
"""
@tornado.web.asynchronous
@gen.coroutine
def get(self):
database = self.settings['db']
query = utils.unpack_params(self)
Expand All @@ -319,7 +320,7 @@ def get(self):
else:
raise compose_err_msg(500, 'No results found!')

@tornado.web.asynchronous
@gen.coroutine
def post(self):
database = self.settings['db']
data = ujson.loads(self.request.body.decode("utf-8"))
Expand Down Expand Up @@ -350,7 +351,7 @@ def post(self):
'SampleHandler expects list or dict')
self.finish(ujson.dumps(uids))

@tornado.web.asynchronous
@gen.coroutine
def put(self):
database = self.settings['db']
incoming = ujson.loads(self.request.body)
Expand All @@ -371,18 +372,18 @@ def put(self):

class SchemaHandler(DefaultHandler):
"""Provides the json used for schema validation provided collection name"""
@tornado.web.asynchronous
@gen.coroutine
def get(self):
col = utils.unpack_params(self)
self.write(utils.schemas[col])
self.finish()

@tornado.web.asynchronous
@gen.coroutine
def put(self):
raise utils._compose_err_msg(405,
status='Not allowed on server')

@tornado.web.asynchronous
@gen.coroutine
def post(self):
raise utils._compose_err_msg(405,
status='Not allowed on server')
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ pymongo
pyyaml
requests
six
tornado<5
tornado
ujson

0 comments on commit fcc6e34

Please sign in to comment.