<s> import tornado . web <EOL> class BaseHandler ( tornado . web . RequestHandler ) : <EOL> @ property <EOL> def db ( self ) : <EOL> return self . application . db <EOL> @ property <EOL> def session ( self ) : <EOL> return self . application . session_engine <EOL> def on_finish ( self ) : <EOL> if self . session and self . session . is_modified : <EOL> self . session . save ( ) <EOL> super ( BaseHandler , self ) . on_finish ( ) </s>
