Newbie: Problems with File IO

Shaun Laughey shaun at laughey.com
Sun Feb 17 16:40:28 EST 2002


If you want to remember them forever (sic) then use cookies.
http://www.python.org/doc/current/lib/module-Cookie.html

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

User connects
Do they have a session?
No - generate one.
Do they have a username?
No - ask for it and store in session username
and
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
help.


Hope this helps
Shaun Laughey,

-----Original Message-----
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 62.2.16.82:

> Flavian Hardcastle <deathtospam43423 at altavista.com> wrote in 
> news:Xns91B873A49D077AusYourStandingInIt at 210.49.20.254:
> 
>> 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
manual 
(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
whether 
a man is wise by his questions."  Naguib Mahfouz

netvegetable at dingoblue.net.au
-- 
http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list