From the standard Python library, we need sys for the standard output stream, sys.stdout. We need os for the
environmental variable dictionary, os.environ. The string module
supplies string.letters and string.digits, from which we pick the cookie's
random characters, and the random module
randomizes those choices. The gdbm module
is the lightweight database that lets us store and
retrieve user information. The time
module is necessary to determine expiration times.
#================================================================ # Imports #---------------------------------------------------------------- import sys, os, string, random, gdbm, time
Specific to Web applications are: Cookie
module, with handy functions for cookie work; urllib for escaping displayed values; and cgi for obtaining name-value pairs passed to the
script. The cgitb module displays a stack
traceback in case the script fails; in a production
script, you would remove the “cgitdb.enable()” that turns on this
traceback feature.
import cgi, urllib, Cookie import cgitb; cgitb.enable()
The lxml.etree module handles XHTML
generation; we import it here as et.
import lxml.etree as et