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

6.6. buildRegionsForm(): Build the table of region radiobuttons

pickaregion.cgi
# - - -   b u i l d R e g i o n s F o r m

def buildRegionsForm(page, db):
    '''Create the form, including the region radiobuttons.

      [ (page is a tp.TCCPage instance) and
        (db is pycbc.TCCDatabase instance) ->
          page  :=  page modified to display a form for selecting a
              regional index page for one of the regions from db ]
   '''

As specified in Section 4.1, “Layout of the top page”, the form contains not only the regional radiobutton set, but also First year no. and Last year no. fields and a Submit button. Those controls are added here.

pickaregion.cgi
    #-- 1
    # [ page.content  +:=  a form element with method='POST' and
    #       action=(the regional index CGI script)
    #   form  :=  that form element ]
    form = subElement(page.content,
        E.form(method=topform.METHOD,
               action='http://www.nmt.edu/~shipman/z/cbc/cbchist/regx.cgi'))

    #-- 2
    # [ form  +:=  (start year number entry) + (end year number entry) +
    #              (submit button) ]
    form.append(
        E.div("Year number 1 is 1900-1901; year number 101 is "
              "2000-2001; in general, the year containing "
              "December minus 1899."))
    form.append(
        E.table({'cellspacing': '20', 'rules': 'none', 'border': '0'},
            E.tr(
                E.td(
                    E.label(lib.FOR(topform.FIRST_YEAR_ID),
                            "First year no."),
                    E.input(name=topform.FIRST_YEAR_ENTRY,
                            id=topform.FIRST_YEAR_ID,
                            type='text', size=4)),
                E.td(
                    E.label(lib.FOR(topform.LAST_YEAR_ID),
                            "Last year no."),
                    E.input(name=topform.LAST_YEAR_ENTRY,
                            id=topform.LAST_YEAR_ID,
                            type='text', size=4)),
                E.td(
                    E.input(type='checkbox', checked='checked',
                            name=topform.OVERLAP_CB,
                            id=topform.OVERLAP_ID),
                    E.label(lib.FOR(topform.OVERLAP_ID),
                        "Show all historical circles that overlap.")))))
    form.append(
        E.div(
            E.input(type='submit', value="Generate a regional index"),
            E.input(type='reset', value="Clear this form")))

See Section 6.7, “addRadios(): Add regional selection radiobuttons”.

pickaregion.cgi
    #-- 3
    # [ form  +:=  radiobuttons to select regions in db ]
    addRadios(form, db)