few fine points before we move on first of allmake sure the web server script we wrote earlier in example - is running before you proceedit' going to catch our requests and route them to our script also notice how this script adds the current working directory (os getcwdto the sys path module search path when it first starts barring pythonpath changethis is required to allow both the pickler and this script itself to import the person module one level up from the script because of the new way the web server runs cgi scripts in python the current working directory isn' added to sys patheven though the shelve' files are located there correctly when opened such details can vary per server the only other feat of semi-magic the cgi script relies on is using record' attribute dictionary (__dict__as the source of values when applying html escapes to field values and string formatting to the html reply template string in the last line of the script recall that %(key)code replacement target fetches value by key from dictionaryd {'say' 'get''shrubbery' ['say' '%(say) =%(get)sd ' =shrubberyby using an object' attribute dictionarywe can refer to attributes by name in the format string in factpart of the reply template is generated by code if its structure is confusingsimply insert statements to print replyhtml and to call sys exitand run from simple command line this is how the table' html in the middle of the reply is generated (slightly formatted here for readability)key name age job pay this text is then filled in with key values from the record' attribute dictionary by string formatting at the end of the script this is done after running the dictionary through utility to convert its values to code text with repr and escape that text per html conventions with cgi escape (againthe last step isn' always requiredbut it' generally good practicethese html reply lines could have been hardcoded in the scriptbut generating them from tuple of field names is more general approach--we can add new fields in the future without having to update the html template each time python' string processing tools make this snap step adding web interface