#NEWLINE# def get_nickname( email , never_me = False , request = None ) : #NEWLINE# #INDENT# "Return a nickname for an email address.\n\n  If 'never_me' is True, 'me' is not returned if 'email' belongs to the\n  current logged in user. If 'request' is a HttpRequest, it is used to\n  cache the nickname returned by models.Account.get_nickname_for_email().\n  " #NEWLINE# if isinstance ( email , users . User ) : #NEWLINE# #INDENT# email = email . email ( ) #NEWLINE# #UNINDENT# if ( not never_me ) : #NEWLINE# #INDENT# if ( request is not None ) : #NEWLINE# #INDENT# user = request . user #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# user = auth_utils . get_current_user ( ) #NEWLINE# #UNINDENT# if ( ( user is not None ) and ( email == user . email ( ) ) ) : #NEWLINE# #INDENT# return 'me' #NEWLINE# #UNINDENT# #UNINDENT# if ( request is None ) : #NEWLINE# #INDENT# return models . Account . get_nickname_for_email ( email ) #NEWLINE# #UNINDENT# if ( getattr ( request , '_nicknames' , None ) is None ) : #NEWLINE# #INDENT# request . _nicknames = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if ( email in request . _nicknames ) : #NEWLINE# #INDENT# return request . _nicknames [ email ] #NEWLINE# #UNINDENT# result = models . Account . get_nickname_for_email ( email ) #NEWLINE# request . _nicknames [ email ] = result #NEWLINE# return result