def connectionPoolAware(pool_name, argument_name=None):
    """This decorator redefines the value of the decorated function argument named <pool_name> 
    and sets it to the connection pool named pool_name defined in the DatabaseConfig class. 
    
    Note: this decorator seems to have no practical use, as it is much easier to fetch 
          a needed connection pool by name using database.get_connection_pool('pool_name')
          directly inside the method. 
    
    Typical way of decorating the method would be::
    
        @connectionPoolAware(pool_name='slave', argument_name='slavePool')
        def test_database_method(slavePool=None)
            with slavePool.context('testing connection pool aware method') as cur
                cur.execute('SELECT VERSION()')
        
        # and then call the defined method like that
        test_database_method()
    """
    def decorator(f):
        """Function wrapper, that returns a callable that wraps decorated function 'f' (passed as a parameter)"""
        def executor(*argv, **kwargs):
            """Actual wrapper, that adds some new parameters to the decorated function 'f'"""
            if databaseConfig :
                if databaseConfig.has_connection_pool(pool_name) :
                    # calculate the argument name to be assigned
                    n = argument_name if argument_name is not None else pool_name
                    p = databaseConfig.get_connection_pool( pool_name )
                    if p :
                        kwargs[ n ] = p
                    else :
                        _logger.error( 'Pool named %s is not initialized', pool_name )
                else :
                    _logger.error( 'Pool named %s is not defined!', pool_name )
            else :
                _logger.error( 'Database configuration should be initialized with fileConfig(fileName) call.')
            f(*argv, **kwargs) #IGNORE:W0142
        return executor
    return decorator
This decorator redefines the value of the decorated function argument named <pool_name> 
    and sets it to the connection pool named pool_name defined in the DatabaseConfig class. 
    
    Note: this decorator seems to have no practical use, as it is much easier to fetch 
          a needed connection pool by name using database.get_connection_pool('pool_name')
          directly inside the method. 
    
    Typical way of decorating the method would be::
    
        @connectionPoolAware(pool_name='slave', argument_name='slavePool')
        def test_database_method(slavePool=None)
            with slavePool.context('testing connection pool aware method') as cur
                cur.execute('SELECT VERSION()')
        
        # and then call the defined method like that
        test_database_method()
    
recipes/Python/577072_Global_database_configuraticontext_aware/recipe-577072.py