<s> from python_rest_handler . prh_async import AsyncRestRequestHandler <EOL> from tornado import gen <EOL> from tornado . web import RequestHandler <EOL> from tornado_rest_handler . motorengine import MotorEngineDataManager <EOL> import python_rest_handler <EOL> import tornado <EOL> class TornadoRestHandler ( RequestHandler , AsyncRestRequestHandler ) : <EOL> async_decorator = gen . coroutine <EOL> @ gen . coroutine <EOL> def get ( self , instance_id = None ) : <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> yield self . rest_handler . get ( instance_id = instance_id ) <EOL> else : <EOL> super ( ) . get ( ) <EOL> @ gen . coroutine <EOL> def post ( self , instance_id = None ) : <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> yield self . rest_handler . post ( instance_id = instance_id ) <EOL> else : <EOL> super ( ) . post ( ) <EOL> @ gen . coroutine <EOL> def put ( self , instance_id ) : <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> yield self . rest_handler . put ( instance_id = instance_id ) <EOL> else : <EOL> super ( ) . put ( ) <EOL> @ gen . coroutine <EOL> def delete ( self , instance_id ) : <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> yield self . rest_handler . delete ( instance_id = instance_id ) <EOL> else : <EOL> super ( ) . delete ( ) <EOL> def raise_error ( self , code ) : <EOL> if code == <NUM_LIT> : <EOL> raise tornado . web . HTTPError ( code , '<STR_LIT>' ) <EOL> elif code == <NUM_LIT> : <EOL> raise tornado . web . HTTPError ( code , '<STR_LIT>' ) <EOL> elif code == <NUM_LIT> : <EOL> raise tornado . web . HTTPError ( code , '<STR_LIT>' ) <EOL> else : <EOL> raise tornado . web . HTTPError ( code ) <EOL> def get_request_uri ( self ) : <EOL> return self . request . uri <EOL> def get_request_data ( self ) : <EOL> data = { } <EOL> for arg in list ( self . request . arguments . keys ( ) ) : <EOL> data [ arg ] = self . get_argument ( arg ) <EOL> if data [ arg ] == '<STR_LIT>' : <EOL> data [ arg ] = None <EOL> return data <EOL> def redirect ( self , url , permanent = False , status = None , ** kwargs ) : <EOL> return super ( ) . redirect ( url , permanent = permanent , status = status ) <EOL> def get_current_user ( self ) : <EOL> return None <EOL> def authorize ( self , action , instances = [ ] , <EOL> instance_id = None , request_data = { } , query_filters = { } ) : <EOL> return True <EOL> def rest_routes ( model , data_manager = MotorEngineDataManager , request_handler = TornadoRestHandler , ** kwargs ) : <EOL> return python_rest_handler . rest_routes ( model , data_manager , request_handler , ** kwargs ) </s>
