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


Python History.put方法代码示例

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


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

示例1: post

# 需要导入模块: from models import History [as 别名]
# 或者: from models.History import put [as 别名]
    def post(self):
        isajax = self.request.get('isajax')
        phone = self.request.get('phone')
        msg = self.request.get('msg')
        contact_name = self.request.get('contact_name')

        user = users.get_current_user()
        email = user.email().lower()
        q = Token.query(Token.email == email)
        token = q.get()
        status = 100
        hist=''
        logging.debug(email + ' ' + phone + ' ' + msg + ' ' + contact_name)
        if token:
            status = 101
            if len(phone) and len(msg):
                status = 200
                hist = History(email=email, msg=msg, phone=phone, contact_name = contact_name)
                hist.put()
                airship.push({
                    "android": {
                         "extra": {"msgid": str(hist.key.id()), "phone": phone, "msg":msg}
                    }
                }, apids=[token.apid])
                id = hist.key.id()
                hist = hist.to_dict()
                hist['created']=hist['created'].isoformat();
                hist['id'] = id
                hist['type'] = 'sms'        
        self.response.out.write(json.dumps({'status':status, 'msg':hist}))
开发者ID:spicavigo,项目名称:onlinesms_server,代码行数:32,代码来源:hello_world.py

示例2: new_game

# 需要导入模块: from models import History [as 别名]
# 或者: from models.History import put [as 别名]
    def new_game(self, request):
        """Creates a Game.
            Args:
            request: The NEW_GAME_REQUEST objects, which includes two players'
                names
            Returns:
                GameForm with created game
            Raises:
                endpoints.NotFoundException: If the user does not exist.
                endpoints.BadRequestException: If the game is created with one
                user.
        """
        user_x = User.query(User.name == request.user_name_x).get()
        user_o = User.query(User.name == request.user_name_o).get()
        if (not user_o) or (not user_x):
            raise endpoints.NotFoundException(
                    'A User with that name does not exist!')
        try:
            game = Game.new_game(user_x.key, user_o.key)
            history = History(game=game.key)
            history.put()
        except ValueError:
            raise endpoints.BadRequestException('Players should be '
                                                'different!')

        return game.to_form('Good luck playing TicTacToe!')
开发者ID:NadiiaLukianenko,项目名称:tictactoegame,代码行数:28,代码来源:api.py

示例3: get

# 需要导入模块: from models import History [as 别名]
# 或者: from models.History import put [as 别名]
 def get(self):
     contact_name = self.request.get('contact_name')    
     phone = self.request.get('phone')
     msg = self.request.get('msg')
     email = self.request.get("email",'').lower()
     hist = History(email=email, msg=msg, phone=phone, contact_name = contact_name, byme=False)
     hist.put()
     id = hist.key.id()
     hist = hist.to_dict()
     hist['created']=hist['created'].isoformat();
     hist['id'] = id
     hist['type'] = 'sms'  
     channel.send_message(email, json.dumps(hist))
     self.response.out.write(json.dumps({}))
开发者ID:spicavigo,项目名称:onlinesms_server,代码行数:16,代码来源:hello_world.py

示例4: create_game

# 需要导入模块: from models import History [as 别名]
# 或者: from models.History import put [as 别名]
    def create_game(self, request):
        """create a new game """

        # look up initiating player
        slinger = Player.query(Player.player_id == request.player_id).get()

        if slinger is None:
            raise endpoints.BadRequestException(
                'specified player_id not found')

        # generate new game
        game_id = uniq_id()
        game = Game(game_id=game_id, player_id=slinger.player_id)
        game.put()

        # create game history for this game
        history = History(game=game.key)
        history.put()

        return game.to_message()
开发者ID:bschmoker,项目名称:highnoon,代码行数:22,代码来源:api.py

示例5: _make_move

# 需要导入模块: from models import History [as 别名]
# 或者: from models.History import put [as 别名]
 def _make_move(self, game, user, at_position, p):
     try:
         history = History(parent=game.key)
         history.user = user.key
         history.guess = p.coordinate
         history.turn = game.turn
         if game.player1_turn:
             history.player_turn = 1
         else:
             history.player_turn = 2
         if at_position <= 0:
             message = 'Miss!'
             history.result = 'miss'
             history.put()
             game.set_fired(user, p.d)
             game.put()
         else:
             message = "Hit!"
             history.result = 'hit'
             ships_query = Ship.query(ancestor=game.key)
             filter_query = ndb.query.FilterNode('user', '=', user.key)
             ships_query1 = ships_query.filter(filter_query)
             filter_query = ndb.query.FilterNode('type', '=', at_position)
             ships_query2 = ships_query1.filter(filter_query)
             ship = ships_query2.get()
             if not ship:
                 filter_query = ndb.query.FilterNode(
                     'type', '=', str(at_position))
                 ships_query3 = ships_query1.filter(filter_query)
                 ship = ships_query3.get()
             ship.hits += 1
             game.set_fired(user, p.d)
             if(ship.is_sank()):
                 message += " Ship %s sank" % ShipType(at_position)
                 game.sink_ship(user, at_position)
             history.put()
             ship.put()
             game.put()
     except ValueError as e:
         raise endpoints.BadRequestException(e)
     return game.to_form(message)
开发者ID:seyfig,项目名称:BattleShip,代码行数:43,代码来源:api.py


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