示例#1
0
def createNewProfile(user):

    # Create an empty profile
    userProfile = UserProfile(user = user)
    userProfile.put()  # save the new (and empty) profile in the Datastore in order to obtain its key
    logging.info("New profile created, key = " + str(userProfile.key()))

    # User settings
    userSettings = UserSettings(parent = userProfile)
    userSettings.put()
    userProfile.userSettings = userSettings

    # Primary email address (needed for notifications, etc.)
    userEmail = UserEmail(parent = userProfile,
                          itemValue = user.email(),  # "*****@*****.**"
                          privacyType = 'Home',
                          primary = True)
    userEmail.put()

    userProfile.defaultGroup  = createNewGroup(userProfile, 'Default')
    userProfile.defaultPersona = createNewPersona(userProfile, 'Default', userEmail)
    userProfile.publicPersona  = createNewPersona(userProfile, 'Public', userEmail)

    # Save the updated user profile
    userProfile.put()

    
    nickname = UserNickname(parent = userProfile,
                            itemValue = user.nickname())
    nickname.put()

    return userProfile
示例#2
0
 def _getUserSettings(self):
     
     return UserSettings.all(). \
                         ancestor(self.userProfile). \
                         get()