示例#1
0
  def __init__(self, queue, player1_id, player2_id, board_size, num_stars):
    self.player1_id = player1_id
    self.player2_id = player2_id
    self.board_size = board_size
    self.num_stars = num_stars

    self.__queue = queue
    threading.Thread.__init__(self)

    # Create the match in the databse
    match = Match(self.player1_id, self.player2_id, self.board_size, self.num_stars)
    with transaction.manager:
      DBSession.add(match)
      DBSession.flush()
      self.match_id = match.match_id
示例#2
0
def new_player(request):

  if request.method == 'POST':
    if 'submit' in request.POST:
      name = request.POST.get('playerName')
      url = request.POST.get('playerUrl')

      if not name or not url:
        return dict(error='Please fill out all fields.')


      new_player = Player(name, url)
      with transaction.manager:
        DBSession.add(new_player)

      raise HTTPFound(request.route_path('index'))
  return dict()