Handling states with HTTP

F

Fred Murray

Hi all,

I've been looking around for a utility that will let me do something like this:

while 1:
# Ask user for username and password
username, password = user_session.form_input(LOGIN_SCREEN)

# If username is invalid, warn user and ask again
if username not in users:
user_session.print(INVALID_USERNAME)
continue

# If password is invalid, warn user and ask again
if users[username] != password:
user_session.print(INVALID_PASSWORD)
continue

# If username and password match, then break out of loop
break

# (code to log in user goes here...)

In other words, I'm looking for a package that will use cookies or CGI
variables to save the state of the program in between HTTP requests. Packages
like Albatross seem to require class definitions for each page, which isn't
as natural or convenient as treating an HTML form as an input function (like
raw_input()).

If anyone knows if anything like this is available, thanks for letting me know!
 
J

John J. Lee

Fred Murray said:
I've been looking around for a utility that will let me do something like this: [...]
like Albatross seem to require class definitions for each page, which isn't
as natural or convenient as treating an HTML form as an input function (like
raw_input()).

If anyone knows if anything like this is available, thanks for letting me know!

Christian Tismer has just written something like this (the only thing
like it in Python, AFAIK)! Search back in recent c.l.py messages on
Google Groups. It's based on Zope, and I'm not sure if he's even
released the code yet.


John
 
J

John P. Speno

In other words, I'm looking for a package that will use cookies or CGI
variables to save the state of the program in between HTTP requests. Packages
like Albatross seem to require class definitions for each page, which isn't
as natural or convenient as treating an HTML form as an input function (like
raw_input()).

I'm sure many of the packages you can find here:

http://www.python.org/cgi-bin/moinmoin/WebProgramming

have some form of session managment that you'll be able to use.

Take a look at pso (Python Service Objects):

http://sourceforge.net/projects/pso/

Having just recently used it, I think pso has exactly what you want.
Here are some examples of its usage for session managment:

http://www.scriptfoundry.com/modules/pso/doc/session-cgi.html

Take care.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,173
Messages
2,570,937
Members
47,481
Latest member
ElviraDoug

Latest Threads

Top