[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1

script, to pass data on to the next script on submit; hidden
form fields provide another way to save state between pages.












When Example 15-15 is opened in a browser, we get the input page in Figure 15-19.


Figure 15-19. tutor5d.html input form page


When submitting, we trigger our original tutor5.py script once again (Exam-
ple 15-12), but some of the inputs have been provided for us as hidden fields. The reply
page is captured in Figure 15-20.


Much like the query parameters of the prior section, here again we’ve hardcoded and
embedded the next page’s inputs in the input page’s HTML itself. Unlike query pa-
rameters, hidden input fields don’t show up in the next page’s address. Like query
parameters, such input fields can also be generated on the fly as part of the reply from
a CGI script. When they are, they serve as inputs for the next page, and so are a sort of
memory—session state passed from one script to the next. To fully understand how
and why this is necessary, we need to next take a short diversion into state retention
alternatives.


Climbing the CGI Learning Curve| 1173
Free download pdf