Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.arcetri.astro.it/~lfini/testform.py
Дата изменения: Tue May 8 14:15:09 2012 Дата индексирования: Sat Apr 9 23:04:35 2016 Кодировка: Поисковые слова: astro-ph |
#!/usr/bin/python
# This CGI script has been generated as part of an FM installation and
# can be used to test that everything is working properly. It can also
# be used as template to make forms suited to your particular needs.
import sys # Just keep this line as it is.
# The following line specifies the directory where you have installed
# FM files. It comes from your answer to the installation procedure questions
# so it could be possibly wrong ;-)
sys.path.append("/home/lfini/py/cgi/FormMaker")
import FM # Keep this also as it is.
# The following three definitions create variables containing text which
# will be used later on. This is to show how python variables can be used
# to simplify the definition of the form. Note the python syntax to allow
# to define strings with embedded newlines
htheader="""
"
fmfooter=" Powered by FormMaker 2.4"
##############################################################################################
# First part: global form definition. The parameters to the following call
# define many general aspects of the form. Most of them are optional and
# can be omitted (suitable defaults will be provided whenever possible).
f=FM.defineForm(name="testf", # Name of the form
workdir="/tmp", # Specify a working directory
# You will find gathered data as records in a file
# named: /tmp/testf.csv
nameprefix="hsurv", # Prefix for file names of registered data. If specified,
# data from the form will be registered also as single
# files named: rec_xxxxxxx.txt
h1="HERSCHEL USE QUESTIONNAIRE", # Form box title
# h2="Useless form", # Form box subtitle.
# An h3 subsubtitle may be also added
expand=True, # If set to True the form box fills up the entire page
footer=fmfooter, # fmfooter is a python string defined above.
# A handy way to specify a long option.
border=1, # Add a border around the form
bgcolor="#C0C0C0", # Form background color (RGB representation)
tdopts="", # Specify here HTML options to be included in the
# table generated by the form. E.g.: id, class, style.
# Multiple options are space separated.
# NB: do not use colspan or rowspan in that they will
# conflict with form layout. May be overridden in Item
# definition (see third part below)
control=FM.NONE, # Access through antispam control.
# Requires the PIL Python package
# Other values: FM.PASSWD - ID/Password authentication
# FM.NONE - no access control
notify="hunt@arcetri.astro.it", # Send notification to these e-mail
# addresses. More address can be specified
# comma-separated in a single string.
notifsubj="New data stored", # Subject in notification messages
sender="huq@arcetri.astro.it", # Sender address in mail messages
smtp="hercules.arcetri.astro.it", # Mail server to send mail
# confirm=FM.DATA, # We also want that a confirmation e-mail
# message be sent to the user. NOTE: this
# requires that a field named "email" is defined
# below. If not, the argument is ignored
# If you use: confirm=FM.FIXED, the form content
# is is not appended to the e-mail message
# confsubj="Confirmation", # Subject in confirmation message
# Message text in confirmation e-mail:
# confmsg="Your data has been recorded as follows:",
dispose=FM.KEEP, # dispose: what to do with data file (FM.KEEP, FM.REMOVE)
process=None) # Specify a routine which will be called to process data.
##############################################################################################
# Second part: define HTML additional code (optional)
f.addHTML(htheader,htfooter) # htheader and htfooter are strings defined above.
# They will be added on top and at bottom of the
# generated web page
##############################################################################################
# Third part: form fields definitions
# Each line defines a data field. The order will be respected in the form.
# All item definitions must have at least the first argument: the field name.
# Field names cannot be duplicated.
f.addItem("name",label="Name",size=10) # Simple text item. If the argument "label" is
# not specified, the field name is used as label
f.addItem("surname",label="Family name") # Here a label is specified
f.addItem("email",label="E-mail addr.") # An item with name "email" is mandatory if the
# "confirm" option has been specified in defineForm()
#f.addMenu("Sex",optlist=["Male","Female"], # This is a menu choice
# label="Gender",
# tdopts="bgcolor=#aa5050") # with different background color
f.addItem("institute",label="Home institute")
f.addHeading("Heading in the middle", # This is an header with different
tdopts="bgcolor=#80f0f0 align=center") # background and centered
f.addRadio("inst_perf",
label="Rate the instrument performance relative to your expectations",
optlist=["1","2","3","4","5"],
align=False)
f.addRadio("inst_docs",
label="Rate the instrument documentation relative to your expectations",
optlist=["1","2","3","4","5"],
align=False)
# in the form
f.addHeading() # Put just some vertical space
f.addTBox("Comments",size=[10,60], # This is a text box 10 rows by 60 columns wide
required=False) # Data in this box is not required
f.addDate() # This adds the current date to the recorded data
# No input field is generated
##############################################################################################
# Fourth part: end of definitions
f.endDefine() # REQUIRED AT END