def ajax(authenticated=True, data_required=False, json_encoder=json.JSONEncoder):
 def decorator(function, authenticated=authenticated, data_required=data_required):
  @functools.wraps(function, assigned=decorators.available_attrs(function))
  def _wrapped(self, request, *args, **kw):
   if (authenticated and (not request.user.is_authenticated())):
    return JSONResponse('not logged in', 401)
   if (not request.is_ajax()):
    return JSONResponse('request must be AJAX', 400)
   request.DATA = None
   if request.body:
    try:
     request.DATA = json.loads(request.body)
    except (TypeError, ValueError) as e:
     return JSONResponse(('malformed JSON request: %s' % e), 400)
   if data_required:
    if (not request.DATA):
     return JSONResponse('request requires JSON body', 400)
   try:
    data = function(self, request, *args, **kw)
    if isinstance(data, http.HttpResponse):
     return data
    elif (data is None):
     return JSONResponse('', status=204)
    return JSONResponse(data, json_encoder=json_encoder)
   except http_errors as e:
    for attr in ['http_status', 'code', 'status_code']:
     if hasattr(e, attr):
      http_status = getattr(e, attr)
      break
    else:
     log.exception('HTTP exception with no status/code')
     return JSONResponse(str(e), 500)
    return JSONResponse(str(e), http_status)
   except Exception as e:
    log.exception('error invoking apiclient')
    return JSONResponse(str(e), 500)
  return _wrapped
 return decorator

def ajax ( authenticated = True , data_required = False , json_encoder = json . JSONEncoder ) : def decorator ( function , authenticated = authenticated , data_required = data_required ) : @ functools . wraps ( function , assigned = decorators . available_attrs ( function ) ) def _wrapped ( self , request , * args , ** kw ) : if ( authenticated and ( not request . user . is_authenticated ( ) ) ) : return JSONResponse ( 'not logged in' , 401 ) if ( not request . is_ajax ( ) ) : return JSONResponse ( 'request must be AJAX' , 400 ) request . DATA = None if request . body : try : request . DATA = json . loads ( request . body ) except ( TypeError , ValueError ) as e : return JSONResponse ( ( 'malformed JSON request: %s' % e ) , 400 ) if data_required : if ( not request . DATA ) : return JSONResponse ( 'request requires JSON body' , 400 ) try : data = function ( self , request , * args , ** kw ) if isinstance ( data , http . HttpResponse ) : return data elif ( data is None ) : return JSONResponse ( '' , status = 204 ) return JSONResponse ( data , json_encoder = json_encoder ) except http_errors as e : for attr in [ 'http_status' , 'code' , 'status_code' ] : if hasattr ( e , attr ) : http_status = getattr ( e , attr ) break else : log . exception ( 'HTTP exception with no status/code' ) return JSONResponse ( str ( e ) , 500 ) return JSONResponse ( str ( e ) , http_status ) except Exception as e : log . exception ( 'error invoking apiclient' ) return JSONResponse ( str ( e ) , 500 ) return _wrapped return decorator
query for a user matching a given email .