(request)
return HttpResponse(json.dumps(result), content_type="application/json")
returns json-encoded lists of layer identifiers that
    represent the sets of read-write and read-only layers
    for the currently authenticated user.
returns json-encoded lists of layer identifiers that
    represent the sets of read-write and read-only layers
    for the currently authenticated user.
returns json - encoded lists of layer identifiers that represent the sets of read - write and read - only layers for the currently authenticated user .
def dataset_acls(request):
    """
    returns json-encoded lists of layer identifiers that
    represent the sets of read-write and read-only layers
    for the currently authenticated user.
    """
    # the dataset_acls view supports basic auth, and a special
    # user which represents the geoserver administrator that
    # is not present in django.
    acl_user = request.user
    if 'HTTP_AUTHORIZATION' in request.META:
        try:
            username, password = _get_basic_auth_info(request)
            acl_user = authenticate(username=username, password=password)

            # Nope, is it the special geoserver user?
            if (acl_user is None and
                    username == ogc_server_settings.USER and
                    password == ogc_server_settings.PASSWORD):
                # great, tell geoserver it's an admin.
                result = {
                    'rw': [],
                    'ro': [],
                    'name': username,
                    'is_superuser': True,
                    'is_anonymous': False
                }
                return HttpResponse(
                    json.dumps(result),
                    content_type="application/json")
        except Exception:
            pass

        if acl_user is None:
            return HttpResponse(_("Bad HTTP Authorization Credentials."),
                                status=401,
                                content_type="text/plain")

    # Include permissions on the anonymous user
    # use of polymorphic selectors/functions to optimize performances
    resources_readable = get_objects_for_user(
        acl_user, 'view_resourcebase',
        ResourceBase.objects.filter(polymorphic_ctype__model='dataset')).values_list('id', flat=True)
    dataset_writable = get_objects_for_user(
        acl_user, 'change_dataset_data',
        Dataset.objects.all())

    _read = set(
        Dataset.objects.filter(
            id__in=resources_readable).values_list(
            'alternate',
            flat=True))
    _write = set(dataset_writable.values_list('alternate', flat=True))

    read_only = _read ^ _write
    read_write = _read & _write

    result = {
        'rw': list(read_write),
        'ro': list(read_only),
        'name': acl_user.username,
        'is_superuser': acl_user.is_superuser,
        'is_anonymous': acl_user.is_anonymous,
    }
    if acl_user.is_authenticated:
        result['fullname'] = acl_user.get_full_name()
        result['email'] = acl_user.email

    return HttpResponse(json.dumps(result), content_type="application/json")
def dataset_acls ( request ) : # the dataset_acls view supports basic auth, and a special # user which represents the geoserver administrator that # is not present in django. acl_user = request . user if 'HTTP_AUTHORIZATION' in request . META : try : username , password = _get_basic_auth_info ( request ) acl_user = authenticate ( username = username , password = password ) # Nope, is it the special geoserver user? if ( acl_user is None and username == ogc_server_settings . USER and password == ogc_server_settings . PASSWORD ) : # great, tell geoserver it's an admin. result = { 'rw' : [ ] , 'ro' : [ ] , 'name' : username , 'is_superuser' : True , 'is_anonymous' : False } return HttpResponse ( json . dumps ( result ) , content_type = "application/json" ) except Exception : pass if acl_user is None : return HttpResponse ( _ ( "Bad HTTP Authorization Credentials." ) , status = 401 , content_type = "text/plain" ) # Include permissions on the anonymous user # use of polymorphic selectors/functions to optimize performances resources_readable = get_objects_for_user ( acl_user , 'view_resourcebase' , ResourceBase . objects . filter ( polymorphic_ctype__model = 'dataset' ) ) . values_list ( 'id' , flat = True ) dataset_writable = get_objects_for_user ( acl_user , 'change_dataset_data' , Dataset . objects . all ( ) ) _read = set ( Dataset . objects . filter ( id__in = resources_readable ) . values_list ( 'alternate' , flat = True ) ) _write = set ( dataset_writable . values_list ( 'alternate' , flat = True ) ) read_only = _read ^ _write read_write = _read & _write result = { 'rw' : list ( read_write ) , 'ro' : list ( read_only ) , 'name' : acl_user . username , 'is_superuser' : acl_user . is_superuser , 'is_anonymous' : acl_user . is_anonymous , } if acl_user . is_authenticated : result [ 'fullname' ] = acl_user . get_full_name ( ) result [ 'email' ] = acl_user . email return HttpResponse ( json . dumps ( result ) , content_type = "application/json" )