# Classes class FormState(UserDict) class StickyForm(Form)
# Functions def compare_f2f(f1, f2) def compare_s2f(s, f2) def dump(data, filename) def escape(text, replace=string.replace) def imgsize(path) def load(filename) def markup_re(text, rex=None, marker=None, collapse=0) def mpath(path) def overlay_values(obj, dict) def relpath(path1, path2)
# Variables string CONTYPE = 'Content-Type: text/html\0 ... string DOCTYPE = '<!DOCTYPE HTML PUBLIC "-/ ... int I_am_a_list = 1 string __file__ = '/usr/local/lib/python1.5/ ... string __version__ = '1.0.1'
It is a class which works with HTMLgen to provide state
maintaining forms. Forms can load and save their state to and
from files. This persistent state is what makes them sticky
.
The same reason you'd want to use CGI.pm ;) Actually there are many CGI tasks which benefit from forms which can remember their settings. For example, in a hypothetical CGI program, a user could set their preferences with a form, and later return to the form to modify or review them.
Simply create forms the same way you normally would with HTMLgen, only use the StickyForm class instead of the Form class.
StickyForm works like a Form with the addition of a state attribute, a save method and a restore method.
You can set a form's state when you create it, and you can always change the state later by assigning something else to the form's state attribute.
form=StickyForm(state="/tmp/form.txt")
cgi_results=cgi.FieldStorage() form=StickyForm(state=cgi_results)
fs=FormState() form=StickyForm(state=fs)
This is a simple dictionary which StickyForm uses to store its state information. A FormState instance can be intitalized with a FieldStorage instance, to create a form state which reflects the form data in the FieldStorage instance. This just means turning a slightly complex FieldStorage into a simple dictionary.
It is pickled to a file.
Yes, see the StickyForm page.
UserDict UserList cPickle copy os re string time
Copyright © Amos Latteier
All Rights Reserved
Comments to author: amos@aracnet.com
Generated: Tue Apr 20, 1999