#NEWLINE# def create_profile( self , user ) : #NEWLINE# #INDENT# "\n        Create a ``RegistrationProfile`` for a given\n        ``User``, and return the ``RegistrationProfile``.\n        \n        The activation key for the ``RegistrationProfile`` will be a\n        SHA1 hash, generated from a combination of the ``User``'s\n        username and a random salt.\n        \n        " #NEWLINE# salt = sha_constructor ( str ( random . random ( ) ) ) . hexdigest ( ) [ : 5 ] #NEWLINE# username = user . username #NEWLINE# if isinstance ( username , unicode ) : #NEWLINE# #INDENT# username = username . encode ( 'utf-8' ) #NEWLINE# #UNINDENT# activation_key = sha_constructor ( ( salt + username ) ) . hexdigest ( ) #NEWLINE# return self . create ( user = user , activation_key = activation_key )