(restore_state, cache_bucket_prefix, fixture_name, data_fn)
return [data.replace(global_id, b_user_id)] if data else []
Get the fixture data for a global fixture (one that does not vary by user).

    :param restore_state: Restore state object used to access features of the restore
    :param cache_bucket_prefix: Fixture bucket prefix
    :param fixture_name: Name of the fixture
    :param data_fn: Function to generate the XML fixture elements
    :return: list containing byte string representation of the fixture
Get the fixture data for a global fixture (one that does not vary by user).
Get the fixture data for a global fixture ( one that does not vary by user ) .
def get_or_cache_global_fixture(restore_state, cache_bucket_prefix, fixture_name, data_fn):
    """
    Get the fixture data for a global fixture (one that does not vary by user).

    :param restore_state: Restore state object used to access features of the restore
    :param cache_bucket_prefix: Fixture bucket prefix
    :param fixture_name: Name of the fixture
    :param data_fn: Function to generate the XML fixture elements
    :return: list containing byte string representation of the fixture
    """
    domain = restore_state.restore_user.domain

    data = None
    key = '{}/{}'.format(cache_bucket_prefix, domain)

    if not restore_state.overwrite_cache:
        data = get_cached_fixture_items(domain, cache_bucket_prefix)
        _record_datadog_metric('cache_miss' if data is None else 'cache_hit', key)

    if data is None:
        with CriticalSection([key]):
            if not restore_state.overwrite_cache:
                # re-check cache to avoid re-computing it
                data = get_cached_fixture_items(domain, cache_bucket_prefix)
                if data is not None:
                    return [data]

            _record_datadog_metric('generate', key)
            items = data_fn()
            io_data = write_fixture_items_to_io(items)
            data = io_data.read()
            io_data.seek(0)
            cache_fixture_items_data(io_data, domain, fixture_name, cache_bucket_prefix)

    global_id = GLOBAL_USER_ID.encode('utf-8')
    b_user_id = restore_state.restore_user.user_id.encode('utf-8')
    return [data.replace(global_id, b_user_id)] if data else []
def get_or_cache_global_fixture ( restore_state , cache_bucket_prefix , fixture_name , data_fn ) : domain = restore_state . restore_user . domain data = None key = '{}/{}' . format ( cache_bucket_prefix , domain ) if not restore_state . overwrite_cache : data = get_cached_fixture_items ( domain , cache_bucket_prefix ) _record_datadog_metric ( 'cache_miss' if data is None else 'cache_hit' , key ) if data is None : with CriticalSection ( [ key ] ) : if not restore_state . overwrite_cache : # re-check cache to avoid re-computing it data = get_cached_fixture_items ( domain , cache_bucket_prefix ) if data is not None : return [ data ] _record_datadog_metric ( 'generate' , key ) items = data_fn ( ) io_data = write_fixture_items_to_io ( items ) data = io_data . read ( ) io_data . seek ( 0 ) cache_fixture_items_data ( io_data , domain , fixture_name , cache_bucket_prefix ) global_id = GLOBAL_USER_ID . encode ( 'utf-8' ) b_user_id = restore_state . restore_user . user_id . encode ( 'utf-8' ) return [ data . replace ( global_id , b_user_id ) ] if data else [ ]