def updateProfile(profileVO): user = users.get_current_user() if user: # Does the profile already exist? if profileVO.key == None: # No, create a new profile. profile = UserProfile() #logging.info("Creating a new profile!") else: # Yes, get the existing profile from the data store. profile = UserProfile.get(profileVO.key) #logging.debug("Updating existing profile...") # Update and save the profile. profile.user = user profile.name = profileVO.name profile.url = profileVO.url try: profile.description = profileVO.description except AttributeError: #logging.info("Profile description was empty, so we're skipping it.") pass profile.save() return {'name': profile.name, 'url': profile.url, 'description': profile.description, 'key': profileVO.key} return False
def login(base_url, login_return_url): user = users.get_current_user() # The user value object (VO) contains login and logout URLs. # (With /gateway stripped out so that it returns to the SWF). urls = getUrls(base_url, login_return_url) user_vo = { 'login': urls['login'], 'logout': urls['logout'], 'auth': False } if user: # Add the user object to the user VO. user_vo['user'] = user user_vo['auth'] = True # Get the user's profile from the database profile = UserProfile.all().filter('user ='******'profile'] = { 'name': profile.name, 'url': profile.url, 'description': profile.description, 'key': str(profile.key()) } return user_vo