当前位置: 首页>>代码示例>>Python>>正文


Python Profile.get_profile_unique_name_from_profile_display_name方法代码示例

本文整理汇总了Python中models.profile.Profile.get_profile_unique_name_from_profile_display_name方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.get_profile_unique_name_from_profile_display_name方法的具体用法?Python Profile.get_profile_unique_name_from_profile_display_name怎么用?Python Profile.get_profile_unique_name_from_profile_display_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.profile.Profile的用法示例。


在下文中一共展示了Profile.get_profile_unique_name_from_profile_display_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import get_profile_unique_name_from_profile_display_name [as 别名]

#.........这里部分代码省略.........
                    edit_profile_url += '/'
                edit_profile_url += 'edit_profile'

                feedback = urllib.quote(feedback, safe='')
                feedback_status = urllib.quote(feedback_status, safe='')

                return self.redirect(edit_profile_url + '?feedback=' + feedback + '&feedback_status=' + feedback_status)
            else:
                # The profile already exists and is for this user:
                profile_changed = False
                if bio is None and profile_obj_for_profile_name.bio is not None:
                    profile_obj_for_profile_name.bio = None
                    profile_changed = True
                if profile_changed:
                    update_success = True
                    try:
                        profile_obj_for_profile_name.put()
                    except:
                        update_success = False
                    if update_success:
                        feedback = 'Successfully updated your profile.'
                        feedback_status = 'Success'
                    else:
                        feedback = 'Attempt to update your profile failed.'
                        feedback_status = 'Failure'
                elif feedback is None:
                    feedback = 'Your profile information is unchanged.'
                    feedback_status = 'No_Change'
                edit_profile_url = self.request.application_url
                if not re.match(r"^.*$", edit_profile_url):
                    edit_profile_url += '/'
                edit_profile_url += 'edit_profile'

                feedback = urllib.quote(feedback, safe='')
                feedback_status = urllib.quote(feedback_status, safe='')

                return self.redirect(edit_profile_url + '?feedback=' + feedback + '&feedback_status=' + feedback_status)
        elif profile_obj_for_user is not None:
            # The user has a profile object
            profile_unique_name = Profile.get_profile_unique_name_from_profile_display_name(profile_unique_display_name)
            if profile_unique_name != profile_obj_for_user.profile_unique_name:
                # Request to change the profile unique name:
                # First, delete the existing profile object:
                delete_sucess = True
                try:
                    profile_obj_for_user.key.delete()
                except:
                    delete_sucess = False
                if not delete_sucess:
                    feedback = 'Attempt to update your profile failed.'
                    feedback_status = 'Failure'
                else:
                    # Next, create a new profile object using the new profile unique name:
                    new_profile_success = True
                    try:
                        new_profile_obj = Profile.add_profile(profile_unique_display_name, application_user_id, bio=bio)
                    except:
                        new_profile_success = False
                    if new_profile_success:
                        feedback = 'Successfully updated your profile.'
                        feedback_status = 'Success'
                    else:
                        feedback = 'Attempt to update your profile failed.'
                        feedback_status = 'Failure'
            else:
                feedback = 'Your profile information is unchanged.'
                feedback_status = 'No_Change'

            edit_profile_url = self.request.application_url
            if not re.match(r"^.*$", edit_profile_url):
                edit_profile_url += '/'
            edit_profile_url += 'edit_profile'

            feedback = urllib.quote(feedback, safe='')
            feedback_status = urllib.quote(feedback_status, safe='')

            return self.redirect(edit_profile_url + '?feedback=' + feedback + '&feedback_status=' + feedback_status)
        else:
            # Create a new profile for this user:
            new_profile_success = True
            try:
                new_profile_obj = Profile.add_profile(profile_unique_display_name, application_user_id, bio=bio)
            except:
                new_profile_success = False
            if new_profile_success:
                feedback = 'Successfully created your profile.'
                feedback_status = 'Success'
            else:
                feedback = 'Attempt to create your profile failed.'
                feedback_status = 'Failure'

            edit_profile_url = self.request.application_url
            if not re.match(r"^.*$", edit_profile_url):
                edit_profile_url += '/'
            edit_profile_url += 'edit_profile'

            feedback = urllib.quote(feedback, safe='')
            feedback_status = urllib.quote(feedback_status, safe='')

            return self.redirect(edit_profile_url + '?feedback=' + feedback + '&feedback_status=' + feedback_status)
开发者ID:peterjirak,项目名称:sweetvisionart2,代码行数:104,代码来源:edit_profile.py


注:本文中的models.profile.Profile.get_profile_unique_name_from_profile_display_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。