from apistar.http import Response from .component import Session, DBSession class SQLAlchemyHook: def on_request(self, session: Session): return def on_response(self, session: Session, response: Response): DBSession.remove() return response def on_error(self, session: Session, response: Response): session.rollback() DBSession.remove() return response