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

(yzsuai) #1

Figure 16-9 shows one that gives the Python exception and details as part of the reply
after a Python-raised exception is caught; as usual, the exception details are fetched
from sys.exc_info, and Python’s traceback module is used to generate a stack trace.


Passing State Information in URL Link Parameters


The central mechanism at work in Example 16-7 is the generation of URLs that embed
message numbers and mail account information. Clicking on any of the View links in
the selection list triggers another script, which uses information in the link’s URL pa-
rameters to fetch and display the selected email. As mentioned in Chapter 15, because
the list’s links are programmed to “know” how to load a particular message, they ef-
fectively remember what to do next. Figure 16-10 shows part of the HTML generated
by this script (use your web browser View Source option to see this for yourself—I did
a Save As and then opened the result which invoked Internet Explorer’s source viewer
on my laptop).


Did you get all the details in Figure 16-10? You may not be able to read generated HTML
like this, but your browser can. For the sake of readers afflicted with human-parsing


Figure 16-9. PyMailCGI login error page


1254 | Chapter 16: The PyMailCGI Server

Free download pdf