def connection_callback(isolation_level=None,
                        read_only=None,
                        deferrable=None,
                        application_name=None,
                        inherit=None):
    """
    Decorator for functions used in :meth:`IConnectionManager.open_and_call`.

    When the function is called, it will be given a connection that has
    the given traits.

    Use ``inherit=BaseClass.func`` when you're overriding a callback
    function ``func``.
    """
    if inherit is not None:
        isolation_level = isolation_level or inherit.transaction_isolation_level
        application_name = application_name or inherit.transaction_application_name
        read_only = read_only or inherit.transaction_read_only
        deferrable = deferrable or inherit.transaction_deferrable
    def f(func):
        func.transaction_isolation_level = isolation_level
        func.transaction_read_only = read_only
        func.transaction_deferrable = deferrable
        func.transaction_application_name = application_name
        return func
    return f