1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<!-- This file generated using Python HTMLgen module. -->
<HEAD>
<META NAME="GENERATOR" CONTENT="HTMLgen 2.2.2">
<TITLE>Module StickyForm - StickyForm -- state maintaining HTML forms</TITLE>
<LINK rel=stylesheet href="HTMLgen.css" type=text/css title="HTMLgen.css">
</HEAD>
<BODY BGCOLOR="#FFFFFF" BACKGROUND="../image/bg-dots.gif" TEXT="#000000" LINK="#EE0000" VLINK="#990000">
<A HREF="Formtools_overview.html"><IMG src="../image/back.gif" height="22" width="66" alt="Previous" border="0"></A>
<A HREF="cgiapp_overview.html"><IMG src="../image/next.gif" height="22" width="66" alt="Next" border="0"></A>
<IMG src="../image/blank.gif" height="22" width="66" alt="blank.gif">
<IMG src="../image/blank.gif" height="22" width="66" alt="blank.gif">
<H3>Module StickyForm - StickyForm -- state maintaining HTML forms</H3>
<HR>
<H2>SYNOPSIS</H2>
<PRE># Classes
<A HREF="StickyForm-FormState.html">class FormState(UserDict)</A>
<A HREF="StickyForm-StickyForm.html">class StickyForm(Form)</A>
</PRE>
<PRE># Functions
def compare_f2f(f1, f2)
def compare_s2f(s, f2)
def dump(data, filename)
<A HREF="StickyForm-escape.html">def escape(text, replace=string.replace)</A>
<A HREF="StickyForm-imgsize.html">def imgsize(path)</A>
def load(filename)
<A HREF="StickyForm-markup_re.html">def markup_re(text, rex=None, marker=None, collapse=0)</A>
<A HREF="StickyForm-mpath.html">def mpath(path)</A>
<A HREF="StickyForm-overlay_values.html">def overlay_values(obj, dict)</A>
<A HREF="StickyForm-relpath.html">def relpath(path1, path2)</A>
</PRE>
<PRE># 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'
</PRE>
<H2>DESCRIPTION</H2>
<H3>Intended to work with HTMLgen.</H3>
<H4> What is StickyForm?</H4>
<P> 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 <CODE>sticky</CODE>
.</P>
<H4> Why would I want to use it?</H4>
<P> 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.</P>
<H4> How do I use it?</H4>
<P> Simply create forms the same way you normally would with
HTMLgen, only use the StickyForm class instead of the Form
class.</P>
<P> StickyForm works like a Form with the addition of a state
attribute, a save method and a restore method.</P>
<DL>
<DT><B> state</B><DD>is a FormState instance which holds the default values
for all form elements.
<DT><B> save</B><DD>tells the FormState instance to save itself to a file.
<DT><B> restore</B><DD>tells the FormState instance to restore itself from a file.
</DL>
<H4> So how do I set a form's state?</H4>
<P> 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.</P>
<H4> There are three ways to indicate a StickyForm's state upon initialization:</H4>
<DL>
<DT><B> filename</B><DD>this loads the state of the form from a file
<DT><B> FieldStorage</B><DD>this sets the state of the form from the
information in the FieldStorage
<DT><B> FormState</B><DD>this sets the state to the FormState instance
</DL>
<H4> For each method here are some examples:</H4>
<PRE> form=StickyForm(state="/tmp/form.txt")</PRE>
<PRE> cgi_results=cgi.FieldStorage()
form=StickyForm(state=cgi_results)</PRE>
<PRE> fs=FormState()
form=StickyForm(state=fs)</PRE>
<H4> What is the FormState class?</H4>
<P> 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.</P>
<H4> How is the form's state saved?</H4>
<P> It is pickled to a file.</P>
<H4> Does StickyForm work with Bobo or DocumentTemplate?</H4>
<P> Yes, see the <A HREF="http://www.aracnet.com/~amos/stickyform/">StickyForm page</A>.</P>
<H2>SEE ALSO</H2>
<PRE><A HREF="UserDict_overview.html">UserDict</A>
<A HREF="UserList_overview.html">UserList</A>
<A HREF="cPickle_overview.html">cPickle</A>
<A HREF="copy_overview.html">copy</A>
<A HREF="os_overview.html">os</A>
<A HREF="re_overview.html">re</A>
<A HREF="string_overview.html">string</A>
<A HREF="time_overview.html">time</A>
</PRE>
<P><HR>
<A HREF="Formtools_overview.html"><IMG src="../image/back.gif" height="22" width="66" alt="Previous" border="0"></A>
<A HREF="cgiapp_overview.html"><IMG src="../image/next.gif" height="22" width="66" alt="Next" border="0"></A>
<IMG src="../image/blank.gif" height="22" width="66" alt="blank.gif">
<IMG src="../image/blank.gif" height="22" width="66" alt="blank.gif">
<BR><IMG src="../image/Buzz.gif" height="51" width="56" alt="Buzz.gif" align="bottom">
<FONT SIZE="-1"><P>Copyright © Amos Latteier<BR>All Rights Reserved<BR>
Comments to author: <A HREF="mailto:amos@aracnet.com">amos@aracnet.com</A><br>
Generated: Tue Apr 20, 1999 <BR><hr>
</FONT>
</BODY> </HTML>
|