#NEWLINE# def get( self , profile_id = None ) : #NEWLINE# #INDENT# 'HTML GET handler.\n    \n    Check the query parameters for the ID of the profile to be displayed.\n    If found, display the user. Otherwise display current user' #NEWLINE# template_values = self . build_template_values ( ) #NEWLINE# if ( profile_id and template_values [ handlers . base . PROFILE_KEY ] and ( int ( profile_id ) == template_values [ handlers . base . PROFILE_KEY ] . key ( ) . id ( ) ) ) : #NEWLINE# #INDENT# template_values [ 'viewed_profile' ] = favorites [ handlers . base . PROFILE_KEY ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if profile_id : #NEWLINE# #INDENT# template_values [ 'viewed_profile' ] = Profile . get_by_id ( int ( profile_id ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if template_values [ handlers . base . PROFILE_KEY ] : #NEWLINE# #INDENT# return self . redirect ( self . uri_for ( 'profile' , profile_id = template_values [ handlers . base . PROFILE_KEY ] . key ( ) . id ( ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . forbidden ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# favorites = Vote . all ( ) . filter ( 'voter = ' , template_values [ 'viewed_profile' ] ) . filter ( 'is_up = ' , True ) . fetch ( 1 ) #NEWLINE# if favorites : #NEWLINE# #INDENT# template_values [ 'recent_up_monster' ] = favorites [ 0 ] . monster #NEWLINE# #UNINDENT# created = Monster . get_recent ( 1 , creator = template_values [ 'viewed_profile' ] , user = template_values [ handlers . base . PROFILE_KEY ] ) #NEWLINE# if created : #NEWLINE# #INDENT# template_values [ 'recent_monster' ] = created [ 0 ] #NEWLINE# #UNINDENT# template = configuration . site . jinja_environment . get_template ( 'profile/view.html' ) #NEWLINE# return self . response . write ( template . render ( template_values ) )