docs: def update_value_from_mapping(source_resource_attr_id, target_resource_attr_id, source_scenario_id, target_scenario_id, **kwargs):
      """
          Using a resource attribute mapping, take the value from the source and apply
          it to the target. Both source and target scenarios must be specified (and therefor
          must exist).
      """
      user_id = int(kwargs.get('user_id'))
  
      rm = aliased(ResourceAttrMap, name='rm')
      #Check the mapping exists.
      mapping = db.DBSession.query(rm).filter(
          or_(
              and_(
                  rm.resource_attr_id_a == source_resource_attr_id,
                  rm.resource_attr_id_b == target_resource_attr_id
              ),
              and_(
                  rm.resource_attr_id_a == target_resource_attr_id,
                  rm.resource_attr_id_b == source_resource_attr_id
              )
          )
      ).first()
  
      if mapping is None:
          raise ResourceNotFoundError("Mapping between %s and %s not found"%
                                      (source_resource_attr_id,
                                       target_resource_attr_id))
  
      #check scenarios exist
      s1 = _get_scenario(source_scenario_id, user_id)
      s2 = _get_scenario(target_scenario_id, user_id)
  
      rs = aliased(ResourceScenario, name='rs')
      rs1 = db.DBSession.query(rs).filter(rs.resource_attr_id == source_resource_attr_id,
                                      rs.scenario_id == source_scenario_id).first()
      rs2 = db.DBSession.query(rs).filter(rs.resource_attr_id == target_resource_attr_id,
                                      rs.scenario_id == target_scenario_id).first()
  
      #3 possibilities worth considering:
      #1: Both RS exist, so update the target RS
      #2: Target RS does not exist, so create it with the dastaset from RS1
      #3: Source RS does not exist, so it must be removed from the target scenario if it exists
      return_value = None#Either return null or return a new or updated resource scenario
      if rs1 is not None:
          if rs2 is not None:
              log.info("Destination Resource Scenario exists. Updating dastaset ID")
              rs2.dataset_id = rs1.dataset_id
          else:
              log.info("Destination has no data, so making a new Resource Scenario")
              rs2 = ResourceScenario(resource_attr_id=target_resource_attr_id, scenario_id=target_scenario_id, dataset_id=rs1.dataset_id)
              db.DBSession.add(rs2)
          db.DBSession.flush()
          return_value = rs2
      else:
          log.info("Source Resource Scenario does not exist. Deleting destination Resource Scenario")
          if rs2 is not None:
              db.DBSession.delete(rs2)
  
      db.DBSession.flush()
      return return_value