timeout bug fixed. main.handler() now automatically updates timeout.
This commit is contained in:
parent
230f04c758
commit
e7e9c72e54
2 changed files with 17 additions and 11 deletions
6
login.py
6
login.py
|
@ -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,11 +78,7 @@ 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>')
|
||||
|
||||
def login_form():
|
||||
"""
|
||||
|
|
18
main.py
18
main.py
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue