@require_POST
def update_permissions(request):
  response = {'status': -1, 'message': _('Error')}

  data = json.loads(request.POST['data'])
  doc_id = request.POST['doc_id']
  try:
    doc = Document.objects.get_doc_for_writing(doc_id, request.user)
    doc.sync_permissions(data)

    response['message'] = _('Permissions updated!')
    response['status'] = 0
    response['doc'] = massage_doc_for_json(doc, request.user)
  except __HOLE__, e:
    response['message'] = _('Form is missing %s field') % e.message
  except Exception, e:
    LOG.exception(e.message)
    response['message'] = force_unicode(e)

  return JsonResponse(response)
dataset/ETHPy150Open cloudera/hue/desktop/core/src/desktop/api.py/update_permissions