Esempio n. 1
0
    def run(self):
        """
            Sets up the application, runs the command, and then tears everything down
        """
        system.initialize()

        try:
            RemoteCommand.__LOGGER.debug("Starting remote command: %s", self.__command.command_key)
            AbstractDAO.begin()
            self.__command.run()
            AbstractDAO.commit()
            RemoteCommand.__LOGGER.debug("Finished remote command: %s", self.__command.command_key)
        except Exception:
            RemoteCommand.__LOGGER.exception("Error while running remote command: %s", self.__command.command_key)
            AbstractDAO.rollback()
        finally:
            system.dispose()
Esempio n. 2
0
    def process_response(self, req, resp, resource):
        """
            Post-processing of the response (after routing).

            :param req: The request
            :type req: falcon.Request

            :param resp: The response
            :type resp: falcon.Response
        """
        if resp.status in DAOTransaction.__OK_STATUSES:
            AbstractDAO.commit()
        else:
            assert resp.status not in DAOTransaction.__OK_STATUSES
            AbstractDAO.rollback()

        # close the session
        close_db_connection()