Пример #1
0
def attach_handlers(app, settings):
    """Add callback handlers to ``app`` in the correct order."""
    # Add callback handlers to application
    add_handlers(app, mongo_handlers.handlers)
    add_handlers(app, task_handlers.handlers)
    add_handlers(app, transaction_handlers.handlers)

    # Attach handler for checking view-only link keys.
    # NOTE: This must be attached AFTER the TokuMX to avoid calling
    # a commitTransaction (in toku's after_request handler) when no transaction
    # has been created
    add_handlers(app, {'before_request': framework.sessions.prepare_private_key})
    # framework.session's before_request handler must go after
    # prepare_private_key, else view-only links won't work
    add_handlers(app, {'before_request': framework.sessions.before_request})

    return app
Пример #2
0
def attach_handlers(app, settings):
    """Add callback handlers to ``app`` in the correct order."""
    # Add callback handlers to application
    add_handlers(app, mongo_handlers.handlers)
    add_handlers(app, task_handlers.handlers)
    if settings.USE_TOKU_MX:
        add_handlers(app, transaction_handlers.handlers)

    # Attach handler for checking view-only link keys.
    # NOTE: This must be attached AFTER the TokuMX to avoid calling
    # a commitTransaction (in toku's after_request handler) when no transaction
    # has been created
    add_handlers(app, {'before_request': framework.sessions.prepare_private_key})
    # framework.session's before_request handler must go after
    # prepare_private_key, else view-only links won't work
    add_handlers(app, {'before_request': framework.sessions.before_request})
    return app
Пример #3
0
def attach_handlers(app, settings):
    """Add callback handlers to ``app`` in the correct order."""
    # Add callback handlers to application
    add_handlers(app, mongo_handlers.handlers)
    add_handlers(app, task_handlers.handlers)
    add_handlers(app, transaction_handlers.handlers)

    # Attach handler for checking view-only link keys.
    # NOTE: This must be attached AFTER the TokuMX to avoid calling
    # a commitTransaction (in toku's after_request handler) when no transaction
    # has been created
    add_handlers(app, {'before_request': framework.sessions.prepare_private_key})
    # framework.session's before_request handler must go after
    # prepare_private_key, else view-only links won't work
    add_handlers(app, {'before_request': framework.sessions.before_request})

    # Needed to allow the offload server and main server to properly interact
    # without cors issues. See @jmcarp, @chrisseto, or @icereval for more detail
    if settings.DEBUG_MODE:
        add_handlers(app, {'after_request': add_cors_headers})

    return app
Пример #4
0
def attach_handlers(app, settings):
    """Add callback handlers to ``app`` in the correct order."""
    # Add callback handlers to application
    add_handlers(app, mongo_handlers.handlers)
    add_handlers(app, task_handlers.handlers)
    add_handlers(app, transaction_handlers.handlers)

    # Attach handler for checking view-only link keys.
    # NOTE: This must be attached AFTER the TokuMX to avoid calling
    # a commitTransaction (in toku's after_request handler) when no transaction
    # has been created
    add_handlers(app, {'before_request': framework.sessions.prepare_private_key})
    # framework.session's before_request handler must go after
    # prepare_private_key, else view-only links won't work
    add_handlers(app, {'before_request': framework.sessions.before_request})

    # Needed to allow the offload server and main server to properly interact
    # without cors issues. See @jmcarp, @chrisseto, or @icereval for more detail
    if settings.DEBUG_MODE:
        add_handlers(app, {'after_request': add_cors_headers})

    return app
Пример #5
0
                    'framework.transactions.commands.commit') as mock_commit:
                mock_commit.side_effect = OperationFailure(messages.LOCK_ERROR)
                handlers.transaction_after_request(response)
        transactions = database.command('showLiveTransactions')
        assert_equal(len(transactions['transactions']), 0)
        assert_equal(
            database['txn'].find({
                '_id': key
            }).count(),
            0,
        )


transaction_app = Flask('test_transactions_app')

add_handlers(transaction_app, database_handlers.handlers)
add_handlers(transaction_app, handlers.handlers)


@transaction_app.route('/transact/me/bro/', methods=['GET'])
def transaction_view():
    return make_response()


@handlers.no_auto_transaction
@transaction_app.route('/dont/transact/me/bro/', methods=['GET'])
def no_transaction_view():
    return make_response()


@transaction_app.route('/seriously/bro/', methods=['GET'])
Пример #6
0
        with app.test_request_context(content_type='application/json'):
            response = make_response('bob', 200)
            with mock.patch('framework.transactions.commands.commit') as mock_commit:
                mock_commit.side_effect = OperationFailure(messages.LOCK_ERROR)
                handlers.transaction_after_request(response)
        transactions = database.command('showLiveTransactions')
        assert_equal(len(transactions['transactions']), 0)
        assert_equal(
            database['txn'].find({'_id': key}).count(),
            0,
        )


transaction_app = Flask('test_transactions_app')

add_handlers(transaction_app, database_handlers.handlers)
add_handlers(transaction_app, handlers.handlers)


@transaction_app.route('/transact/me/bro/', methods=['GET'])
def transaction_view():
    return make_response()


@handlers.no_auto_transaction
@transaction_app.route('/dont/transact/me/bro/', methods=['GET'])
def no_transaction_view():
    return make_response()


@transaction_app.route('/seriously/bro/', methods=['GET'])