Newbie: Problems with File IO
shaun at laughey.com
Sun Feb 17 16:40:28 EST 2002
If you want to remember them from post to post during the same "session"
then use a session object (a temporary cookie in effect) or encode a
unique session into the url (not as easy).
pyweblib.session contains all the functions you need.
Then you would simply
Do they have a session?
No - generate one.
Do they have a username?
No - ask for it and store in session username
Call the clean up function periodically to clear out old sessions.
On your page display the session username.
Remember to use try: or has_key or else you will get errors if there is
no username key in the session object.
For pyweblib see http://www.stroeder.com/pylib/PyWebLib/
Documentation isn't a strong point but the library should give you a
Hope this helps
From: python-list-admin at python.org [mailto:python-list-admin at python.org]
On Behalf Of Flavian Hardcastle
Sent: 17 February 2002 02:25
To: python-list at python.org
Subject: Re: Newbie: Problems with File IO
Chris Liechti <cliechti at gmx.net> wrote in
news:Xns91B81F8828230cliechtigmxnet at 220.127.116.11:
> Flavian Hardcastle <deathtospam43423 at altavista.com> wrote in
> news:Xns91B873A49D077AusYourStandingInIt at 18.104.22.168:
>> out_file = open("log.txt", "w")
> mode 'a' does append (thats the one you want), 'w' starts a new file
> for writing, adding a plus 'a+' or 'w+' opens for read/write
Thanx! That's got me a bit further. What part of the standard Python
(the html one you get at Python.org) would that be under?
Also, if you could give me a hint as to how I might get the script to
remember people's usernames everytime they post, that'd be good.
"You can tell whether a man is clever by his answers. You can tell
a man is wise by his questions." Naguib Mahfouz
netvegetable at dingoblue.net.au
More information about the Python-list