(di, old_data_item, get_location, transaction)
return errors
Removes locations from data items and add new ones based on the location column.

    Note the removal does not happen within a context of the "transaction"
Removes locations from data items and add new ones based on the location column.
Removes locations from data items and add new ones based on the location column .
def _process_location_ownership(di, old_data_item, get_location, transaction):
    """Removes locations from data items and add new ones based on the location column.

    Note the removal does not happen within a context of the "transaction"
    """
    errors = []

    old_locations = old_data_item.locations
    for location in old_locations:
        old_data_item.remove_location(location)

    for name in di.get('location', []):
        location_cache = get_location(name)
        if location_cache.is_error:
            errors.append(location_cache.message)
        else:
            old_data_item.add_location(location_cache.location,
                                       transaction=transaction)
    return errors
def _process_location_ownership ( di , old_data_item , get_location , transaction ) : errors = [ ] old_locations = old_data_item . locations for location in old_locations : old_data_item . remove_location ( location ) for name in di . get ( 'location' , [ ] ) : location_cache = get_location ( name ) if location_cache . is_error : errors . append ( location_cache . message ) else : old_data_item . add_location ( location_cache . location , transaction = transaction ) return errors