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


Python User.put方法代码示例

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


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

示例1: get

# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import put [as 别名]
    def get(self):

        user = users.get_current_user()
        #checks to see if we have a user signed in
        if user:
            userProfile = User.getByEmail(user.email())
            #if user profile is empty create one
            if not userProfile:
                userProfile = User()
                userProfile.email = user.email()
                userProfile.nickname = 'Anonymous'
                userProfile.score = 0
                userProfile.played = 0
                userProfile.put()

            template_values = {
                'user': userProfile
            }

            template = jinja_environment.get_template('profile.html')
            self.response.out.write(template.render(template_values))
        #if not is ask them to sign in
        else:
            template_values = {
                'signinurl' : users.create_login_url("/")
            }

            template = jinja_environment.get_template('signin.html')
            self.response.out.write(template.render(template_values))
开发者ID:erniearl,项目名称:levelblocks,代码行数:31,代码来源:Home.py

示例2: GetUserId

# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import put [as 别名]
 def GetUserId(self):
     
     if endpoints.get_current_user() == None:
         raise endpoints.UnauthorizedException("Must log in")
     
     user = User.query(User.username == endpoints.get_current_user().email()).get()
     if user == None:
         user = User(username = endpoints.get_current_user().email())
         user.put()
     return user.key
开发者ID:Leonidpopob,项目名称:tasks,代码行数:12,代码来源:task_api.py

示例3: post

# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import put [as 别名]
    def post(self):
        username = self.request.get("username")
        password = self.request.get("password")
        verify = self.request.get("verify")
        email = self.request.get("email")

        username_error = ""
        password_error = ""
        verify_error = ""
        email_error = ""

        users = db.GqlQuery("select * from User where name='%s'" % escape(username))

        if users.count(1):
            username_error = "User with such name already exists"

        if not valid_username(username):
            username_error = "That's not valid username"

        if not valid_password(password):
            password_error = "That's not valid password"

        if password != verify:
            verify_error = "Your passwords didn't match"

        if email and not valid_email(email):
            email_error = "That's not valid email"

        if username_error or password_error or verify_error or email_error:
            self.render_form(
                username, password, verify, email, username_error, password_error, verify_error, email_error
            )
        else:
            hash_salt = make_hash_salt(username, password)
            user = User(name=username, email=email, hashpw=hash_salt[0], salt=hash_salt[1])
            user.put()

            cookie = "%s|%s" % (user.key().id(), user.hashpw)
            self.response.headers.add_header("Set-Cookie", "ikariblog_user=%s; Path=/" % cookie)
            self.redirect("/blog/welcome")
开发者ID:altmer,项目名称:study-projects,代码行数:42,代码来源:SignupHandler.py

示例4: post

# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import put [as 别名]
    def post(self):
        username = self.request.get('username')
        password = self.request.get('password')
        verify = self.request.get('verify')
        email = self.request.get('email')

        username_error = ""
        password_error = ""
        verify_error = ""
        email_error = ""
        
        users = db.GqlQuery("select * from User where name='%s'" % escape(username) )
        
        if users.count(1):
            username_error = "User with such name already exists"

        if not valid_username(username):
            username_error = "That's not valid username"
            
        if not valid_password(password):
            password_error = "That's not valid password"
        
        if password != verify:
            verify_error = "Your passwords didn't match"
            
        if email and not valid_email(email):
            email_error = "That's not valid email"

        if username_error or password_error or verify_error or email_error:
            self.render_form(username, password, verify, email, username_error, password_error, verify_error, email_error)            
        else:
            hash_salt = make_hash_salt(username, password)
            user = User(name = username, email = email, hashpw = hash_salt[0], salt = hash_salt[1])
            user.put()

            self.set_cookie(user)            
            self.redirect("/wiki/")
开发者ID:altmer,项目名称:study-projects,代码行数:39,代码来源:WikiSignupHandler.py

示例5: post

# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import put [as 别名]
 def post(self):
     success = False
     template_params={}
     username=self.request.get('username')
     password=self.request.get('password')
     android=self.request.get('android')
     use = User.all().filter('username',username)
     if use.count() == 0:
         #no collisions
         nameTaken = False
         if (password is not None) and (password != ""):
             #valid password
             badPass = False
             #create user account
             usernew = User(username=username,password=password)
             usernew.put()
             success=True
             template_params={'success':success}
         else:
             #invalid password
             badPass = True
             template_params={'success':success,'badPass':badPass}
         if android is not None and (android)==1:
             if(badPass):
                 self.response.write("FAIL-BADPASS")
             else:
                 self.response.write("OK")
         else:
             render_template(self,'createUser.html',template_params)
     else:
         if android is not None and (android)==1:
             self.response.write("FAIL-BADNAME")
         else:
             #username taken
             nameTaken = True
             template_params={'success':success,'nameTaken':nameTaken}
             render_template(self,'createUser.html',template_params)
开发者ID:aquafemi,项目名称:Jirga,代码行数:39,代码来源:signup.py


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