#NEWLINE# def get_user( request ) : #NEWLINE# #INDENT# " Lookup a user session or return None if one doesn't exist " #NEWLINE# sess_id = request . cookies . get ( 'session_id' ) #NEWLINE# if ( not sess_id ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# sess = db . query ( UserSession ) . filter ( ( UserSession . session_id == sess_id ) ) . first ( ) #NEWLINE# if ( not sess ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# if ( not sess_id . user ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'username' : sess . user . username , #NEWLINE# #UNINDENT# }