[Tutor] My first counter... is broken.

Kyle Babich kb@mm.st
Thu, 8 Aug 2002 20:10:22 UT


On Thu, 08 Aug 2002 16:42:57 +0200, "Magnus Lycka"
<magnus@thinkware.se> said:
> At 11:36 2002-08-08 +0000, Kyle Babich wrote:
> >I thought I would try to make my first counter.  Once I wrote it and
> >worked a bug out my counter started working... well, sort of.
> >It counted 1, 2, and then it jumped to something in the hundreds, then
> >thousands, and then the page just went white.
> >This is what showed in my error log:
> >
> >Traceback (most recent call last):
> >   File "/home/sites/kmb/www/public_html/njindenial/counter.py", line =
8,
> >   in ?
> >     number =3D int(number)
> >ValueError: int() literal too large: 01213121412131215
>=20
> Can't you guess? Perhaps you could have a look in the file
> after each access, and you might figure it out. (I don't really
> want to take this debugging experience away from you. You will
> probably get this Aha! experience after a while.) Make sure there
> are no parallel executions of the script while you debug it.
>=20
> Hint: What does FILEOBJECT.write() really do? What would
> happen if you called it several times? What is FILEOBJECT.seek()
> for?
>=20

Someone already mentioned the seek so I fixed it.
At some point I'll probably make it a hit counter instead of a regular
counter though.  I've got two ideas for this, either a cookie that
tells the script that it already recieved a hit from that computer or
so it will only take one hit per ip address.  Maybe after that I could
even add a config file, zip it, and put it on hotscripts.

>=20
> --=20
> Magnus Lyck=E5, Thinkware AB
> =C4lvans v=E4g 99, SE-907 50 UME=C5
> tel: 070-582 80 65, fax: 070-612 80 65
> http://www.thinkware.se/  mailto:magnus@thinkware.se
>=20
>=20

--
Kyle