Beispiel #1
0
    def exec_query_set(self, op):

        tx_url = "{0}/{1}".format(self.tx_base_url, op.tx_id)
        statement_param_pair_set = db_util.db_query_set_to_REST_form(
            op.query_set)

        try:
            post_ret = db_util.post_neo4j(tx_url, statement_param_pair_set)
            op.result_set = post_ret['results']
            op.error_set = post_ret['errors']
            if 0 != len(op.error_set):
                raise Neo4JException(op.error_set)

            self.log_committed_queries(statement_param_pair_set)
        except Neo4JException as e:
            # NOTE: python 2.7 loses the stack when reraising the exception.
            # python 3 does the right thing, but gevent doesn't support it yet.
            log.error('REST statement: %r' % statement_param_pair_set)
            log.exception(e)
            raise e
        except Exception as e:
            log.error('REST statement: %r' % statement_param_pair_set)
            log.exception(e)
            raise Exception(
                'failed exec op statements: err: {0}, url: {1}'.format(
                    e.message, tx_url))
Beispiel #2
0
    def begin_tx(self, op):
        tx_open_url = self.tx_base_url

        try:
            #
            # [!] neo4j seems picky about receiving an additional empty statement list
            #
            data = db_util.db_query_set_to_REST_form([])  # open TX with empty query_set
            ret = db_util.post_neo4j(tx_open_url, data)
            tx_commit_url = ret['commit']
            op.parse_tx_id(tx_commit_url)

            log.debug('tx-open: id: {0}, commit-url: {1}'.format(op.tx_id, tx_commit_url))
        except Exception as e:
            raise Exception('failed to open transaction: ' + e.message)
Beispiel #3
0
    def begin_tx(self, op):
        tx_open_url = self.tx_base_url

        try:
            #
            # [!] neo4j seems picky about receiving an additional empty statement list
            #
            data = db_util.db_query_set_to_REST_form(
                [])  # open TX with empty query_set
            ret = db_util.post_neo4j(tx_open_url, data)
            tx_commit_url = ret['commit']
            op.parse_tx_id(tx_commit_url)

            log.debug('tx-open: id: {0}, commit-url: {1}'.format(
                op.tx_id, tx_commit_url))
        except Exception as e:
            raise Exception('failed to open transaction: ' + e.message)
Beispiel #4
0
    def exec_query_set(self, op):

        tx_url = "{0}/{1}".format(self.tx_base_url, op.tx_id)
        statement_param_pair_set = db_util.db_query_set_to_REST_form(op.query_set)

        try:
            post_ret = db_util.post_neo4j(tx_url, statement_param_pair_set)
            op.result_set = post_ret['results']
            op.error_set = post_ret['errors']
            if 0 != len(op.error_set):
                raise Neo4JException(op.error_set)

            self.log_committed_queries(statement_param_pair_set)
        except Neo4JException as e:
            # NOTE: python 2.7 loses the stack when reraising the exception.
            # python 3 does the right thing, but gevent doesn't support it yet.
            log.error('REST statement: %r' % statement_param_pair_set)
            log.exception(e)
            raise e
        except Exception as e:
            log.error('REST statement: %r' % statement_param_pair_set)
            log.exception(e)
            raise Exception('failed exec op statements: err: {0}, url: {1}'.format(e.message, tx_url))