#NEWLINE# def authorize_user_context( context , user_id ) : #NEWLINE# #INDENT# 'Ensures a request has permission to access the given user.' #NEWLINE# if is_user_context ( context ) : #NEWLINE# #INDENT# if ( not context . user_id ) : #NEWLINE# #INDENT# raise exception . NotAuthorized ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( context . user_id != user_id ) : #NEWLINE# #INDENT# raise exception . NotAuthorized ( )