saving state in Python/CGI
Frank Gibbons
fgibbons at hms.harvard.edu
Fri Sep 20 13:56:21 EDT 2002
Hi,
I've been using Python (and Jython) for about 5 months now. So far, so
great. I'm building a CGI app that has about 5 different stages, and I need
to maintain state between them. Specifically, it's a scientific tool that
requires the user to upload a (possibly quite large) datafile, processes
it, does some computation, then hands it back (formatted) with results.
I need access to the data on each page, yet don't want to pass it as a
hidden field, because of its potential size. In Perl, I could just use the
save() method from CGI.pm to save the form on the server side, pass a
session key in a hidden field, then retrieve the data using the key. For
the life of me, I can't find an equivalent way in Python. cgiFormStorage
looks like a dictionary, but it's immutable, so you can't retrieve data
from disk and add it to the form. cgi.py appears to have no analog to
CGI.pm's save() method, at least not that I've been able to find. I've
tried pickling the form, but that doesn't work either (it saves something
to disk alright, but not the large data retrieved from a multi-part form
file upload).
Perhaps I've missed something. Maybe that's just not how you do things in
Python. Can anyone help?
Thanks,
-Frank Gibbons
PhD, Computational Biologist,
Harvard Medical School BCMP/SGM-322, 250 Longwood Ave, Boston MA 02115, USA.
Tel: 617-432-3555 Fax:
617-432-3557 http://llama.med.harvard.edu/~fgibbons
More information about the Python-list
mailing list