#NEWLINE# @ login_required #NEWLINE# def session_create( request ) : #NEWLINE# #INDENT# data = json . loads ( request . body ) #NEWLINE# try : #NEWLINE# #INDENT# session_id = Session ( auth_token = request . user . password ) . create ( data ) #NEWLINE# #UNINDENT# except UnauthorizedException : #NEWLINE# #INDENT# logger . warning ( 'User unauthorized. Signing out...' ) #NEWLINE# return signout ( request ) #NEWLINE# #UNINDENT# except Exception as inst : #NEWLINE# #INDENT# logger . error ( 'Unexpected exception' , exc_info = True ) #NEWLINE# return render ( request , '500.html' , { #NEWLINE# #INDENT# 'message' : inst . message , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# url = reverse ( 'session_details' , args = ( session_id , ) ) #NEWLINE# return HttpResponse ( url )