timeout bug fixed. main.handler() now automatically updates timeout.

This commit is contained in:
phear 2005-09-14 15:08:44 +00:00
parent 230f04c758
commit e7e9c72e54
2 changed files with 17 additions and 11 deletions

View file

@ -1,12 +1,10 @@
import psql,init_webgo,helper,gamecreation
import time
from mod_python import *
def process_form(req,form):
"""
reads username and password from form
"""
#if form == empty (which means if page is displayed for the first time):
req.write(str(form.keys()))
#req.write("<br>"+"name="+form['name']+", password="+form['password']+"<hr>")
if form.keys() != []:
@ -80,12 +78,8 @@ def game_overview_form(req,user,sessionid):
#display "You have ... free game slots" + Button "create game"
#bei "create game neue funktion zum Erstellen + Mitspieler aus Liste auswählen.
data+=helper.footer()
#check for timeout:
if (psql.get_user_info(user,'timeout') >= int(time.time())) and (sessionid == psql.get_user_info(user,'sessionid')):
req.write(data)
else:
req.write('your session timed out. -- sessionid: '+sessionid+' -- <hr>')
req.write(data)
def login_form():
"""
print welcome message and html form.

18
main.py
View file

@ -4,11 +4,11 @@ simple cgi wrapper for a cgi script, prints the error of the script as html
taken from http://gnosis.cx/publish/programming/feature_5min_python.html
modified a little
"""
import sys, traceback,string,time
import init_webgo,psql
from mod_python import *
import sys, traceback,string
import init_webgo
DEBUG = 1
@ -23,10 +23,23 @@ def handler(req):
#load form, then delegate request
form = util.FieldStorage(req)
try:
sessionid=form["sessionid"]
username=form["username"]
except:
sessionid=""
username=""
foundx = False
for item in form.keys():
if string.find(item,").x") > 0:
foundx = True
#if sessionid=sesssionid and time < timeout:
# set_timeout
if (psql.get_user_info(username,'timeout') > int(time.time())) and (sessionid == psql.get_user_info(username,'sessionid')):
psql.set_user_timeout(username)
if "create" in form.keys():
gamecreation = apache.import_module("gamecreation")
gamecreation.main(req,form)
@ -42,7 +55,6 @@ def handler(req):
login.main(req,form)
return apache.OK
except:
import time
errtime = '----- '+ time.ctime(time.time()) +' -----\n'
errlog = open('/tmp/cgi_errors.log', 'a')
errlog.write(errtime)