On Tue, Jul 29, 2008 at 9:34 PM, Loic Dachary <[EMAIL PROTECTED]> wrote: > > It absolutely makes sense. I will fix the server accordingly tomorrow > by replacing > > packet.tourney = > copy.copy(self.tourneys[tourney_serial].__dict__) > > with a lookup in the database. This function should not rely on the > in-core data structure describing the tournament. I'll leave out the > prize pool for now. >
Hi, I've applied the attached patch and came across the attached error when joining a tournament. Any advices ? -- bou ^
Index: pokernetwork/pokerservice.py
===================================================================
--- pokernetwork/pokerservice.py (revision 4180)
+++ pokernetwork/pokerservice.py (working copy)
@@ -690,25 +690,28 @@
def tourneyManager(self, tourney_serial):
packet = PacketPokerTourneyManager()
packet.tourney_serial = tourney_serial
+ cursor = self.db.cursor(DictCursor)
+ cursor.execute("SELECT user_serial, tourney_serial, table_serial, rank FROM user2tourney WHERE tourney_serial = %d" % tourney_serial)
+ packet.user2tourney = cursor.fetchall()
+ table2serials = {}
+ for row in packet.user2tourney:
+ table_serial = row['table_serial']
+ if table_serial == None:
+ continue
+ if not table2serials.has_key(table_serial):
+ table2serials[table_serial] = []
+ table2serials[table_serial].append(row['user_serial'])
+ packet.table2serials = table2serials
+ packet.user2money = {}
+ if len(table2serials) > 0:
+ cursor.execute("SELECT user_serial, money FROM user2table WHERE table_serial IN ( " + ",".join(map(lambda x: str(x), table2serials.keys())) + " )")
+ for row in cursor.fetchall():
+ packet.user2money[row['user_serial']] = row['money']
+
+ cursor.execute("SELECT user_serial, name FROM user2tourney, users WHERE user2tourney.tourney_serial = " + str(tourney_serial) + " AND user2tourney.user_serial = users.serial")
+ packet.user2name = dict((str(entry["user_serial"]), entry["name"]) for entry in cursor.fetchall())
+ cursor.close()
if self.tourneys.has_key(tourney_serial):
- cursor = self.db.cursor(DictCursor)
- cursor.execute("SELECT user_serial, tourney_serial, table_serial, rank FROM user2tourney WHERE tourney_serial = %d" % tourney_serial)
- packet.user2tourney = cursor.fetchall()
- table2serials = {}
- for row in packet.user2tourney:
- table_serial = row['table_serial']
- if table_serial == None:
- continue
- if not table2serials.has_key(table_serial):
- table2serials[table_serial] = []
- table2serials[table_serial].append(row['user_serial'])
- packet.table2serials = table2serials
- packet.user2money = {}
- if len(table2serials) > 0:
- cursor.execute("SELECT user_serial, money FROM user2table WHERE table_serial IN ( " + ",".join(map(lambda x: str(x), table2serials.keys())) + " )")
- for row in cursor.fetchall():
- packet.user2money[row['user_serial']] = row['money']
- cursor.close()
from pprint import pprint
packet.tourney = copy.copy(self.tourneys[tourney_serial].__dict__)
for key in [ 'cancel', 'create_game', 'destroy_game', 'game_filled', 'move_player', 'new_state', 'remove_player' ]:
Index: tests/test-pokerservice.py.in
===================================================================
--- tests/test-pokerservice.py.in (revision 4180)
+++ tests/test-pokerservice.py.in (working copy)
@@ -756,6 +756,7 @@
'table_serial': 606,
'tourney_serial': 100,
'user_serial': 4},), packet.user2tourney)
+ self.assertEqual({str(self.user1_serial): 'user1'}, packet.user2name)
self.assertEqual(True, packet.tourney.has_key('payouts'))
self.assertEqual(tourney_serial, packet.tourney['serial'])
self.assertEqual(table_money, packet.user2money[self.user1_serial])
poker-network-tourney-manager-user2name.log
Description: Binary data
_______________________________________________ Pokersource-users mailing list [email protected] https://mail.gna.org/listinfo/pokersource-users
