Next / Previous / Contents / TCC Help System / NM Tech homepage

10.10. hist.cgi: buildXhtmlBody(): Main report logic

hist.cgi
# - - -   b u i l d X h t m l B o d y

def buildXhtmlBody(sox, db, txny, circleList, cbcHist):
    '''Generate the entire history report.

      [ (sox is a sox.Sox instance) and
        (db is a pycbc.CBCDatabase instance) and
        (txny is an xnomo3.Txny instance) and
        (circleList is a list of pycbc.Circle instances) and
        (cbcHist is a lib.CbcHist instance) ->
            sox  +:=  the history report from db as specified by
                HistArgs() using the phylogenetic order from txny ]
    '''

Before the main table, we output a general heading followed by the primary index entry or entries for all selected circles. We use an instance of the same class (Section 22, “class PriIndex: Primary regional index entry”) that generates these entries on the regional index page, and then call only the .soxMain() method of that instance—the part that generates the first, boldfaced line, but without the submit button.

hist.cgi
    #-- 1
    # [ if the circle centers in HistArgs().latLonList all match circles
    #   in db ->
    #     circleList  :=  those circles as a sequence of Circle
    #                     records
    #   else -> raise ScriptError ]
    # [ sox  +:=  primary index entries for the circles in circleList ]
    for circle in circleList:
        #-- 1 body
        # [ sox  +:=  primary index entry for circle, limited by year
        #             range in HistArgs() ]
        priIndex = lib.PriIndex(db, circle,
            firstYear=HistArgs().firstYear,
            lastYear=HistArgs().lastYear)
        priIndex.soxMain(sox)

Build an XHTML table and use methods of the CBCHist instance to add output headings and census rows to it. Note that the key row (first heading row) must be repeated periodically. See Section 10.21, “hist.cgi: outputAllRows(): Build the body of the table”.

hist.cgi
    #-- 2
    # [ sox  +:=  headings and all census rows from cbcHist ]
    outputAllRows(sox, cbcHist)