Re: [Karrigell-main] Session and counter
Brought to you by:
quentel
From: Pierre Q. <que...@wa...> - 2003-10-23 06:34:29
|
In Python, to test if an object has an attribute called "Compteur", use : h= asattr(object,"Compteur"). The has_component method of session objects in K= arrigell refer to components as defined in the documentation (a script or a= set of scripts) So if you change your script to : sessionObj=3DSession() print "<html><head></head><body>" print hasattr(sessionObj,"Compteur") if not hasattr(sessionObj,"Compteur"): sessionObj.Compteur =3D 0 else: sessionObj.Compteur =3D sessionObj.Compteur + 1 print sessionObj.Compteur print "<form action=3D\"session_test.py\">" print "<input type=3D\"submit\" name=3D\"Test\" value=3D\"Test\">" print "</form>" print "</body></html>" it should work much better !=20 Cordialement, Pierre Message du 22/10/03 21:58=20 De : Patrick Installe=20 A : kar...@li...=20 Copie =E0 :=20 Objet : [Karrigell-main] Session and counter=20 I just try Karrigell (1.3b) for several of days and Python (2.3.2) for a=20 several week, so I a sort of beginner.=20 I wonder why my little script "session_test.py", which just try to count=20 the number of calls, doesn't work.=20 Thanks a lot in advance=20 Patrick Install=E9=20 Making program foolproof is very difficult because fool are so=20 imaginative (anonymous)=20 #-------------------------------------------------------------=20 sessionObj=3DSession()=20 print ""=20 print sessionObj.has_component("Compteur")=20 if False =3D=3D sessionObj.has_component("Compteur"):=20 sessionObj.Compteur =3D 0=20 else:=20 sessionObj.Compteur =3D sessionObj.Compteur + 1=20 print sessionObj.Compteur=20 print " "=20 print ""=20 print " "=20 print ""=20 #-------------------------------------------------------------=20 -------------------------------------------------------=20 This SF.net email is sponsored by OSDN developer relations=20 Here's your chance to show off your extensive product knowledge=20 We want to know what you know. Tell us and you have a chance to win $100=20 http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54=20 _______________________________________________=20 Karrigell-main mailing list=20 Kar...@li...=20 https://lists.sourceforge.net/lists/listinfo/karrigell-main |