docs: def get_all_resource_data(scenario_id, include_metadata='N', page_start=None, page_end=None, **kwargs):
      """
          A function which returns the data for all resources in a network.
          -
      """
  
      rs_qry = db.DBSession.query(
                 ResourceAttr.attr_id,
                 Attr.name.label('attr_name'),
                 ResourceAttr.id.label('resource_attr_id'),
                 ResourceAttr.ref_key,
                 ResourceAttr.network_id,
                 ResourceAttr.node_id,
                 ResourceAttr.link_id,
                 ResourceAttr.group_id,
                 ResourceAttr.project_id,
                 ResourceAttr.attr_is_var,
                 ResourceScenario.scenario_id,
                 ResourceScenario.source,
                 Dataset.id.label('dataset_id'),
                 Dataset.name.label('dataset_name'),
                 Dataset.value,
                 Dataset.unit_id,
                 Dataset.hidden,
                 Dataset.type,
                 null().label('metadata'),
                 case([
                      (ResourceAttr.node_id != None, Node.name),
                      (ResourceAttr.link_id != None, Link.name),
                      (ResourceAttr.group_id != None, ResourceGroup.name),
                      (ResourceAttr.network_id != None, Network.name),
                 ]).label('ref_name'),
                ).join(ResourceScenario, ResourceScenario.resource_attr_id==ResourceAttr.id)\
                  .join(Dataset, ResourceScenario.dataset_id==Dataset.id).\
                  join(Attr, ResourceAttr.attr_id==Attr.id).\
                  outerjoin(Node, ResourceAttr.node_id==Node.id).\
                  outerjoin(Link, ResourceAttr.link_id==Link.id).\
                  outerjoin(ResourceGroup, ResourceAttr.group_id==ResourceGroup.id).\
                  outerjoin(Network, ResourceAttr.network_id==Network.id).\
              filter(ResourceScenario.scenario_id==scenario_id)
  
      all_resource_data = rs_qry.all()
  
      if page_start is not None and page_end is None:
          all_resource_data = all_resource_data[page_start:]
      elif page_start is not None and page_end is not None:
          all_resource_data = all_resource_data[page_start:page_end]
  
      log.info("%s datasets retrieved", len(all_resource_data))
  
      if include_metadata == 'Y':
          metadata_qry = db.DBSession.query(distinct(Metadata.dataset_id).label('dataset_id'),
                                        Metadata.key,
                                        Metadata.value).filter(
                              ResourceScenario.resource_attr_id==ResourceAttr.id,
                              ResourceScenario.scenario_id==scenario_id,
                              Dataset.id==ResourceScenario.dataset_id,
                              Metadata.dataset_id==Dataset.id)
  
          log.info("Querying node metadata")
          metadata = metadata_qry.all()
          log.info("%s metadata items retrieved", len(metadata))
  
          metadata_dict = {}
          for m in metadata:
              if metadata_dict.get(m.dataset_id):
                  metadata_dict[m.dataset_id].append(m)
              else:
                  metadata_dict[m.dataset_id] = [m]
  
      return_data = []
      for ra in all_resource_data:
          ra_dict = ra._asdict()
          if ra.hidden == 'Y':
             try:
                  d = db.DBSession.query(Dataset).filter(
                          Dataset.id==ra.dataset_id
                      ).options(noload('metadata')).one()
                  d.check_read_permission(kwargs.get('user_id'))
             except:
                 ra_dict['value']     = None
                 ra_dict['metadata']  = []
          else:
              if include_metadata == 'Y':
                  ra_dict['metadata'] = metadata_dict.get(ra.dataset_id, [])
  
          return_data.append(namedtuple('ResourceData', ra_dict.keys())(**ra_dict))
  
      log.info("Returning %s datasets", len(return_data))
  
      return return_data