當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。