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


Python UserModel.put方法代码示例

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


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

示例1: insert_user

# 需要导入模块: from models.user import UserModel [as 别名]
# 或者: from models.user.UserModel import put [as 别名]
 def insert_user(self, request):
     current_user = endpoints.get_current_user()
     if current_user is None:
         raise endpoints.UnauthorizedException('Authorization required')
     
     logging.info('user '+str(current_user))
     user_id = (current_user.user_id() if current_user is not None and current_user.user_id() is not None
              else 'Anonymous')
     email = (current_user.email() if current_user is not None
              else '[email protected]')
     query = UserModel.query(UserModel.email == email).fetch()
     logging.info('LEN '+str(len(query)))
     userDb = None
     if len(query) > 0:
         userDb = query[0]
         logging.info('DB '+str(userDb))
     else:
         userDb = UserModel(user_id=user_id , email=email)
         userDb.key = ndb.Key('UserModel',email)
         userDb.put()
     
     key = userDb.key.urlsafe()
     #key = userDb.key.id()
     user = User(user_id=userDb.user_id,
                 email=userDb.email,
                 key=str(key))
     
     return user
开发者ID:jmn8718,项目名称:gae-endpoint-app,代码行数:30,代码来源:backend_api.py

示例2: add_user

# 需要导入模块: from models.user import UserModel [as 别名]
# 或者: from models.user.UserModel import put [as 别名]
def add_user(user):
    logging.info("user " + str(user))
    user_id = user.user_id() if user is not None and user.user_id() is not None else "Anonymous"
    email = user.email() if user is not None else "[email protected]"
    query = UserModel.query(UserModel.email == email).fetch()
    logging.info("LEN " + str(len(query)))
    userDb = None
    if len(query) > 0:
        userDb = query[0]
        logging.info("DB " + str(userDb))
    else:
        userDb = UserModel(user_id=user_id, email=email)
        userDb.key = ndb.Key("UserModel", email)
        userDb.put()
    return userDb
开发者ID:jmn8718,项目名称:gae-endpoint-app,代码行数:17,代码来源:public.py

示例3: post

# 需要导入模块: from models.user import UserModel [as 别名]
# 或者: from models.user.UserModel import put [as 别名]
 def post(self):
     username = cgi.escape(self.request.get("inputUsername"))
     email = cgi.escape(self.request.get("inputEmail"))
     password = cgi.escape(self.request.get("inputPassword"))
     if(email is not None and password is not None):
         logging.info('Register '+username+" - "+email+" - "+password)
         user = UserModel(user_id=username, email=email, password=password)
         userKey = user.put()
         logging.info(userKey)
         logging.info(userKey.id())
         logging.info(userKey.kind())
         userDb = userKey.get()
         logging.info(userDb)
     else:
         template = JINJA_ENVIRONMENT.get_template('templates/pages/register.html')
         self.response.write(template.render())
开发者ID:jmn8718,项目名称:gae-endpoint-app,代码行数:18,代码来源:user.py


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