docs: def get_attribute_datasets(attr_id, scenario_id, **kwargs):
      """
          Retrieve all the datasets in a scenario for a given attribute.
          Also return the resource attributes so there is a reference to the node/link
      """
  
      user_id = kwargs.get('user_id')
  
      scenario_i = _get_scenario(scenario_id, user_id)
  
      try:
          a = db.DBSession.query(Attr).filter(Attr.id == attr_id).one()
      except NoResultFound:
          raise HydraError("Attribute %s not found"%(attr_id,))
  
      rs_qry = db.DBSession.query(ResourceScenario).filter(
                  ResourceAttr.attr_id==attr_id,
                  ResourceScenario.scenario_id==scenario_i.id,
                  ResourceScenario.resource_attr_id==ResourceAttr.id
              ).options(joinedload_all('dataset'))\
              .options(joinedload_all('resourceattr'))\
              .options(joinedload_all('resourceattr.node'))\
              .options(joinedload_all('resourceattr.link'))\
              .options(joinedload_all('resourceattr.resourcegroup'))\
              .options(joinedload_all('resourceattr.network'))
  
      resourcescenarios = rs_qry.all()
  
      json_rs = []
      #Load the metadata too
      for rs in resourcescenarios:
          rs.dataset.metadata
          tmp_rs = JSONObject(rs)
          tmp_rs.resourceattr=JSONObject(rs.resourceattr)
          if rs.resourceattr.node_id is not None:
              tmp_rs.resourceattr.node = JSONObject(rs.resourceattr.node)
          elif rs.resourceattr.link_id is not None:
              tmp_rs.resourceattr.link = JSONObject(rs.resourceattr.link)
          elif rs.resourceattr.group_id is not None:
              tmp_rs.resourceattr.resourcegroup = JSONObject(rs.resourceattr.resourcegroup)
          elif rs.resourceattr.network_id is not None:
              tmp_rs.resourceattr.network = JSONObject(rs.resourceattr.network)
  
          json_rs.append(tmp_rs)
  
  
      return json_rs