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


Python User.put方法代码示例

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


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

示例1: get

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
 def get(self):
     name = self.request.get('name')
     email = self.request.get('post')
     user = User(name=name, email=email)
     user.put()
     message = '<ul><li>%s, %s</li></ul>' % (name, email)
     self.response.write(message)
开发者ID:eileenrose,项目名称:eileenrose.github.io,代码行数:9,代码来源:nocluewhatiwasdoing.py

示例2: post

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
    def post(self):
        """ Handle the sign-up request. """
        email = self.request.get("email")
        pwd = self.request.get("password")
        verify = self.request.get("verify")

        # there is verification on browser by JS, but validating again won't hurt
        if not self._validate(email, pwd, verify):
            logging.error("How could the invalid input pass the JS test? @auth.SignUpHandler.post()")
            self.redirect("/signup")
            return

        if User.exists(email):
            # telling user that the email has been taken
            self._error("Email registered by others")
        else:
            hashed = encrypt.hash_pwd(email, pwd)
            u = User(email=email,
                     pwd_hashed=hashed,
                     parent=utils.get_key_public('User'))
            u.put()
            self._init_user(u)

            self._set_id_cookie(email)
            self.redirect('/me')
开发者ID:AndriyLin,项目名称:Books,代码行数:27,代码来源:__init__.py

示例3: get

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
    def get(self):        
        http = decorator.http()
        service = build("plus", "v1", http=http)
        # Call the service using the authorized Http object.
        request = service.people().get(userId="me")
        response = request.execute(http=http)
        user_id=response['id']
        name=response['displayName']
        image=response['image']['url']

        self.render("home.html")

        try:
            # Get the db.User that represents the user on whose behalf the
            # consumer is making this request.
            #user = oauth.get_current_user("https://www.googleapis.com/auth/userinfo.email")
            if response:
                greeting = ('Welcome, %s! (<a href="%s">sign out</a>)' %
                        (name, users.create_logout_url('/')))
                entity = User.by_user_id(user_id)
                self.write(greeting)
                if entity is None:
                    entity = User(user_id=user_id, picture=image, name=name)
                    entity.put()
                template_values = {"user":entity, "greeting":greeting}
                #self.redirect('/profile') 
            else:
                self.render("home.html")    

        except oauth.OAuthRequestError, e:
            self.write("Error")  
开发者ID:minakhan01,项目名称:GoogleScholarsHackathon14,代码行数:33,代码来源:main.py

示例4: post

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
 def post(self):
     results_template = env.get_template('results.html')
     template_variables = {
         'message':self.request.get("message"),
         'name':self.request.get("name"),
         'email':self.request.get("email")
         }
     u = User(name=template_variables['name'], email=template_variables['email'])
     u.put()
     self.response.out.write(results_template.render(template_variables))
开发者ID:eileenrose,项目名称:eileenrose.github.io,代码行数:12,代码来源:nocluewhatiwasdoing.py

示例5: post

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
 def post(self):
     user = User()
     user.picture = "http://upload.wikimedia.org/wikipedia/commons/7/7f/Emma_Watson_2013.jpg"
     user.email = self.request.get('email')
     user.age = int(self.request.get('age'))
     user.tagline = self.request.get('mission')
     user.tags = self.request.get('tags').split(",")
     user.intersts = self.request.get('interests')
     user.put()
     template_values = {"user":user}
     self.render("profile.html", **template_values)
开发者ID:minakhan01,项目名称:GoogleScholarsHackathon14,代码行数:13,代码来源:main.py

示例6: create_user

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
 def create_user(self, request):
     """Creates a User. Requires a unique username.
     """
     if User.query(User.name == request.user_name).get():
         raise endpoints.ConflictException(
             'A User with that name already exists!')
     user = User(name=request.user_name, email=request.email)
     user.put()
     # return StringMessage(message='User {} created!'.format(
     #         request.user_name))
     return user.to_form()
开发者ID:dianafisher,项目名称:yahtzee,代码行数:13,代码来源:yahtzee.py

示例7: add_user

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
  def add_user(self, u_name, u_type):
      u = User(name = u_name, type = u_type)

      self.response.write("""
          <p>
              <b>Usuario adicionado:</b><br/>
              <b>Nome: </b> %s <br/>
              <b>Tipo: </b> %s
          </p>
          """ %(u.name, u.type))

      u.put()

      Mailer.send_mail(self, "[email protected]", "Novo usuario", "Novo usuario cadastrado:\n\tNome: %s\n\tTipo: %s" %(u_name, u_type))
开发者ID:SeuRAUL,项目名称:GAE-PD,代码行数:16,代码来源:academy.py

示例8: post

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
    def post(self):
        #get parameters out of the request
        user_username = self.request.get('username')
        user_password = self.request.get('password')

        username = valid_username(user_username)
        password = valid_password(user_password)

        params = {"username": username, "password": password}

        errors = {"username": "That is not a valid username.",
                  "password": "That is not a valid password."}

        #login is validated
        if username and password:
            user_logged_in = self.check_if_logged_in()[0]
            if user_logged_in:
                previous_url = memcache.get("current path")
                self.redirect(previous_url)

            if not user_logged_in:
                #if first time, set a cookie
                new_cookie_val = make_secure_val(username)
                self.response.headers.add_header('Set-Cookie', 'username = %s' % str(new_cookie_val), path = '/')
                u = User(username = username, password = new_cookie_val)
                u.put()
                #need to change this to url just came from if can
                previous_url = memcache.get("current path")
                self.redirect(previous_url)

        else:
        #figure out which is in error
            username_error = ""
            password_error = ""

            password = ""

            for param in params:
                if params[param] == False or params[param] == None:
                    if param == 'username':
                        username_error = errors[param]
                    if param == 'password':
                        password_error = errors[param]

            self.write_form(username_error, password_error,user_username, password)
开发者ID:ErikaNana,项目名称:WebDevelopmentFinal,代码行数:47,代码来源:login.py

示例9: post

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

        username = escape(user_username)
        email = escape(user_email)
        if self.validate(username, user_password, user_verify, email):
            u = User(username=username,
                password_hash=User.get_password_hash(user_password), email=email)
            u.put()
            self.response.headers.add_header('Set-Cookie', 'user=%s; Path=/' %
                self.generate_cookie(u.key().id()))
            self.redirect('/')
        else:
            self.render_form(username, email)
开发者ID:horacix,项目名称:cs253,代码行数:20,代码来源:main.py

示例10: get

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
    def get(self):
        gh_code = self.get_query_argument('code', None)
        if not gh_code:
            return self.redirect('/')

        gh_oauth = OAuth(gh_code)
        yield gh_oauth.set_access_token()

        if not gh_oauth.access_token:
            return self.redirect('/')

        user_data = yield gh_oauth.get_user_data()

        login = user_data['login']
        user = yield User.get(login=login)

        if not user:
            user = User(login, data=user_data, gh_token=gh_oauth.access_token)
            yield user.put()

        self.set_secure_cookie('token', user.token)
        self.redirect('/')
开发者ID:stxnext,项目名称:grot-server,代码行数:24,代码来源:server.py

示例11: get

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
 def get(self):
     username = self.request.get("user")
     password = self.request.get("password")
     email = self.request.get("email")
    
     self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
      
     if not username or not password or not email:
         # some fields were missing in the request
         self.response.write(json_error('invalid', ''))
     else:
         query_user = User.query(User.username == username).fetch()
         query_email = User.query(User.email == email).fetch()
         if query_user:
             # a user with this username exists already
             self.response.write(json_error('failure', 'username'))
         elif query_email:
             # a user with this email exists already
             self.response.write(json_error('failure', 'email'))
         else: 
             # create a new user with the data recieved
             user = User(username = username, pswd = password, email = email)
             db_result = user.put()
             self.response.write(register_response('ok'))
开发者ID:tuvior,项目名称:WhatsFree,代码行数:26,代码来源:register.py

示例12: post

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
    def post(self):
        # get parameters out of the request
        user_username = self.request.get("username")
        user_password = self.request.get("password")
        user_vpassword = self.request.get("verify")
        user_email = self.request.get("email")

        username = valid_username(user_username)
        password = valid_password(user_password)
        vpassword = valid_password(user_vpassword)
        email = valid_email(user_email)

        match = password == vpassword

        params = {"username": username, "password": password, "vpassword": match, "email": email}

        errors = {
            "username": "That is not a valid username.",
            "password": "That is not a valid password.",
            "vpassword": "The passwords don't match.",
            "email": "That is not a valid email address.",
        }

        been_here = visit_cookie_str = self.request.cookies.get("username")

        users = db.GqlQuery("SELECT * from User")
        error_flag = False

        for user in users:
            if user.username == username:
                params["username"] = False
                errors["username"] = "User already exists."
                error_flag = True

        if not error_flag and username and password:
            # log them in
            if not self.check_if_logged_in()[0]:
                self.log_in_user(username)
                # sore user and redirect them to main page
                new_cookie_val = make_secure_val(username)
                u = User(username=username, password=new_cookie_val)
                u.put()
            self.redirect("/")
        else:
            # figure out which is in error
            username_error = ""
            password_error = ""
            matchpw_error = ""
            email_error = ""

            password = ""
            vpassword = ""

            for param in params:
                if params[param] == False or params[param] == None:
                    if param == "username":
                        username_error = errors[param]
                    if param == "password":
                        password_error = errors[param]
                    if param == "vpassword":
                        matchpw_error = errors[param]
                    if param == "email":
                        email_error = errors[param]

            self.write_form(
                username_error,
                password_error,
                matchpw_error,
                email_error,
                user_username,
                password,
                vpassword,
                user_email,
            )
开发者ID:ErikaNana,项目名称:WebDevelopmentFinal,代码行数:76,代码来源:signup.py


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