def METHOD_NAME(collection, user, viewname):
    """Return the data for the named view for the given user logged into the given collection."""
    logger.debug("get_view %s %s %s", collection, user, viewname)
    # setup a generator that looks for the view in the proper discovery order
    matches = ((id, viewset, view, src, level)
               # db first, then disk
               for get_viewsets, src in ((get_viewsets_from_db, 'db'), (load_viewsets, 'disk'))
               # then by directory level
               for level in AR.DIR_LEVELS
               # then in the viewset files in a given directory level
               for id, viewset in get_viewsets(collection, user, level)
               # finally in the list of views in the file
               for view in viewset.findall('views/view[@name=%s]' % quoteattr(viewname)))
    # take the first view from the generator
    try:
        id, viewset, view, source, level = next(matches)
    except StopIteration:
        raise Http404("view: %s not found" % viewname)
    altviews = view.findall('altviews/altview')
    # make a set of the viewdefs the view points to
    viewdefs = set(viewdef
                   for altview in altviews
                   for viewdef in viewset.findall('viewdefs/viewdef[@name=%s]' % quoteattr(altview.attrib['viewdef'])))
    # some viewdefs reference other viewdefs through the 'definition' attribute
    # we will need to make sure those viewdefs are also sent to the client
    def get_definition(viewdef):
        definition = viewdef.find('definition')
        if definition is None: return
        definition_viewdef = viewset.find('viewdefs/viewdef[@name=%s]' % quoteattr(definition.text))
        if definition_viewdef is None:
            raise Http404("no viewdef: %s for definition of viewdef: %s" % (
                    definition.text, viewdef.attrib['name']))
        return definition_viewdef
    # add any viewdefs referenced in other viewdefs to the set
    viewdefs.update([definition
                    for viewdef in viewdefs
                    for definition in [ get_definition(viewdef) ]
                    if definition is not None])
    # build the data to send to the client
    data = view.attrib.copy()
    data['altviews'] = dict((altview.attrib['name'], altview.attrib.copy())
                            for altview in altviews)
    data['viewdefs'] = dict((viewdef.attrib['name'], ElementTree.tostring(viewdef, encoding="unicode"))
                            for viewdef in viewdefs)
    # these properties are useful to see where the view was found for debugging
    data['viewsetName'] = viewset.attrib['name']
    data['viewsetLevel'] = level
    data['viewsetSource'] = source
    data['viewsetId'] = id
    return data