(target_frame_elements, source_datums)
Attempt to match the target session variables with ones in the source session.
    Making some large assumptions about how people will actually use this feature
Attempt to match the target session variables with ones in the source session.
    Making some large assumptions about how people will actually use this feature
Attempt to match the target session variables with ones in the source session . Making some large assumptions about how people will actually use this feature
def _get_datums_matched_to_source(target_frame_elements, source_datums):
    """
    Attempt to match the target session variables with ones in the source session.
    Making some large assumptions about how people will actually use this feature
    """
    unused_source_datums = list(source_datums)
    for target_datum in target_frame_elements:
        if isinstance(target_datum, WorkflowQueryMeta) and isinstance(target_datum.next_datum, WorkflowDatumMeta):
            next_datum = target_datum.next_datum
            if target_datum.is_case_search and next_datum.requires_selection:
                # This query is populating an instance which will be used by the next datum
                # so we need to use the correct case_id session var
                # see RemoteRequestSuiteTest.test_form_linking_to_registry_module
                match = _find_best_match(next_datum, unused_source_datums)
                if match:
                    target_datum.source_id = match.source_id
            yield target_datum
        elif not isinstance(target_datum, WorkflowSessionMeta) or not target_datum.requires_selection:
            yield target_datum
        else:
            match = _find_best_match(target_datum, unused_source_datums)
            if match:
                unused_source_datums = [datum for datum in unused_source_datums if datum.id != match.id]

            yield match if match else target_datum
def _get_datums_matched_to_source ( target_frame_elements , source_datums ) : unused_source_datums = list ( source_datums ) for target_datum in target_frame_elements : if isinstance ( target_datum , WorkflowQueryMeta ) and isinstance ( target_datum . next_datum , WorkflowDatumMeta ) : next_datum = target_datum . next_datum if target_datum . is_case_search and next_datum . requires_selection : # This query is populating an instance which will be used by the next datum # so we need to use the correct case_id session var # see RemoteRequestSuiteTest.test_form_linking_to_registry_module match = _find_best_match ( next_datum , unused_source_datums ) if match : target_datum . source_id = match . source_id yield target_datum elif not isinstance ( target_datum , WorkflowSessionMeta ) or not target_datum . requires_selection : yield target_datum else : match = _find_best_match ( target_datum , unused_source_datums ) if match : unused_source_datums = [ datum for datum in unused_source_datums if datum . id != match . id ] yield match if match else target_datum