def list_sentry_privileges_by_role(request):
  result = {'status': -1, 'message': 'Error'}

  try:
    roleName = request.POST['roleName']
    sentry_privileges = get_api(request.user).list_sentry_privileges_by_role(roleName)
    result['sentry_privileges'] = sorted(sentry_privileges, key=lambda privilege: '%s.%s.%s.%s' % (privilege['server'], privilege['database'], privilege['table'], privilege['URI']))
    result['message'] = ''
    result['status'] = 0
  except Exception, e:
    LOG.exception("could not list sentry privileges")

    result['message'] = unicode(str(e), "utf8")

  return JsonResponse(result)
dataset/ETHPy150Open cloudera/hue/apps/security/src/security/api/hive.py/list_sentry_privileges_by_role/original