Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.stsci.edu/spst/UnixTransition/doc/StickyForm.html
Дата изменения: Fri Apr 8 12:46:13 2016 Дата индексирования: Mon Apr 11 00:37:44 2016 Кодировка: Поисковые слова: m 8 |
StickyForm (version 1.0.1) | index StickyForm.py |
StickyForm -- state maintaining HTML forms
Intended to work with HTMLgen.
What is StickyForm?
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'.
Why would I want to use it?
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.
How do I use it?
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.
state -- is a FormState instance which holds the default values
for all form elements.
save -- tells the FormState instance to save itself to a file.
restore -- tells the FormState instance to restore itself from a file.
So how do I set a form's state?
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.
There are three ways to indicate a StickyForm's state upon initialization:
filename -- this loads the state of the form from a file
FieldStorage -- this sets the state of the form from the
information in the FieldStorage
FormState -- this sets the state to the FormState instance
For each method here are some examples:
form=StickyForm(state="/tmp/form.txt")
cgi_results=cgi.FieldStorage()
form=StickyForm(state=cgi_results)
fs=FormState()
form=StickyForm(state=fs)
What is the FormState class?
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.
How is the form's state saved?
It is pickled to a file.
Does StickyForm work with Bobo or DocumentTemplate?
Yes, see the [StickyForm page].
.. [StickyForm page] http://www.aracnet.com/~amos/stickyform/
Modules | ||||||
|
Classes | ||||||||||||||||||
|
Functions | ||
|
Data | ||
CONTYPE = 'Content-Type: text/html\n\n' DOCTYPE = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">\n<HTML>\n' PRINTECHO = 1 __author__ = 'Amos Latteier, amos@aracnet.com' __version__ = '1.0.1' |
Author | ||
Amos Latteier, amos@aracnet.com |