'Returns the database that should be used for the current request'

def _get_current_database(self):

    if (('request' in box) and ('CURRENT_DATABASE_NAME' not in box)):
        current_db = box['request'].get_host().split('.')[0]
    else:
        current_db = box.get('CURRENT_DATABASE_NAME', 'default')
    return current_db
