def index_data(request, id, repo=None):
    '''Return the fields and values to be indexed for a single object
    as JSON.  Index content is generated via
    :meth:`eulfedora.models.DigitalObject.index_data`.

    :param id: id of the object to be indexed; in this case a Fedora pid
    '''

    # Ensure permission to this resource is allowed. Currently based on IP only.
    if _permission_denied_check(request):
        return HttpResponseForbidden('Access to this web service was denied.', content_type='text/html')

    if repo is None:
        repo_opts = {}
        # if credentials are specified via Basic Auth, use them for Fedora access
        auth_info = request.META.get('HTTP_AUTHORIZATION', None)
        basic = 'Basic '
        if auth_info and auth_info.startswith(basic):
            basic_info = auth_info[len(basic):]
            basic_info_decoded = base64.b64decode(force_bytes(basic_info))
            # NOTE: codecs.decode works everywhere but python 3.3. which
            # complains about an unknown encoding
            # basic_info_decoded = codecs.decode(force_bytes(basic_info), 'base64')
            u, p = force_text(basic_info_decoded).split(':')
            repo_opts.update({'username': u, 'password': p})

        repo = TypeInferringRepository(**repo_opts)
    try:
        obj = repo.get_object(id)
        return HttpResponse(json.dumps(obj.index_data()),
                            content_type='application/json')
    except RequestFailed:
        # for now, treat any failure getting the object from Fedora as a 404
        # (could also potentially be a permission error)
        raise Http404
def index_data ( request , id , repo = None ) : if _permission_denied_check ( request ) : return HttpResponseForbidden ( 'Access to this web service was denied.' , content_type = 'text/html' ) if repo is None : repo_opts = { } auth_info = request . META . get ( 'HTTP_AUTHORIZATION' , None ) basic = 'Basic ' if auth_info and auth_info . startswith ( basic ) : basic_info = auth_info [ len ( basic ) : ] basic_info_decoded = base64 . b64decode ( force_bytes ( basic_info ) ) u , p = force_text ( basic_info_decoded ) . split ( ':' ) repo_opts . update ( { 'username' : u , 'password' : p } ) repo = TypeInferringRepository ( ** repo_opts ) try : obj = repo . get_object ( id ) return HttpResponse ( json . dumps ( obj . index_data ( ) ) , content_type = 'application/json' ) except RequestFailed : raise Http404
Return the fields and values to be indexed for a single object
    as JSON.  Index content is generated via
    :meth:`eulfedora.models.DigitalObject.index_data`.

    :param id: id of the object to be indexed; in this case a Fedora pid