changed database backend to SqlObject. currently unusable until some bugs are fixed.

This commit is contained in:
phear 2005-11-23 17:34:20 +00:00
parent b94b8fbbe9
commit 6474c7f47c
11 changed files with 308 additions and 123 deletions

View file

@ -1,4 +1,4 @@
import goban,helper,psql,login,gnugo
import goban,helper,database,login,gnugo
import string
DEBUG = 1
@ -26,14 +26,15 @@ def create_gobandict(req,form,gamename):
loads sgf, transforms it to dict, writes stuff like player names to dict
returns dict
"""
#read goban table from database
tmplist = psql.read_table(gamename)
#make a dictionary out of the list
tmpdict = psql.fetchall_list_to_goban_dict(tmplist)
sgf = psql.get_sgf(gamename)
#read goban sgf from database
mygame = database.GobanTable.byName(gamename)
sgf = mygame.sgf
gobandict = gnugo.parse_static_gnugo_sgf(sgf)
for key in ["player1","player2","turn_number","name","sgf"]:
gobandict[key] = tmpdict[key]
gobandict["player1"] = mygame.player1
gobandict["player2"] = mygame.player2
gobandict["turn_number"] = mygame.turn_number
gobandict["name"] = mygame.name
gobandict["sgf"] = sgf
return gobandict
def main(req,form):
@ -67,7 +68,7 @@ def main(req,form):
gobandict = create_gobandict(req,form,gamename)
else:
helper.debug(req,form,"its not my turn.")
helper.debug(req,form,"it's not my turn.")
data += """<br>Turn number: %s. %s plays.\n
""" % (str(gobandict["turn_number"]), (string.capitalize(gobandict["play"])))
@ -75,7 +76,7 @@ def main(req,form):
#if yes: print 'your move' and display goban and process move
#if not: print '...s move' and display goban.
if is_my_turn(req,form,gobandict):
data += "<br>Its your turn.<br>\n"
data += "<br>It's your turn.<br>\n"
else:
data += "<br>This is not your turn. You have to wait for the move of the other player.<br>\n"
#print goban