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

8.6. regx.cgi: buildRegionTitles(): Set up the titles for the selected region

regx.cgi
# - - -   b u i l d R e g i o n T i t l e s

def buildRegionTitles(page, db):
    '''Display the region name in the page titles

      [ (page is a tp.TCCPage instance) and
        (db is a pycbc.CBCDatabase instance) ->
          if RegArgs().reg_code is a region code in db ->
            page  :=  page with its titles changed to show the
                      corresponding region
          else -> raise ScriptError ]
    '''
    #-- 1
    # [ if RegArgs().reg_name is a valid region code in db ->
    #     region  :=  the corresponding Region instance
    #   else -> raise ScriptError ]
    reg_code = RegArgs().reg_code
    try:
        region = db.getRegion(reg_code)
    except KeyError:
        raise lib.ScriptError("Unknown region code '%s'." % reg_code)

    #-- 2
    # [ page  :=  page with its titles change to show region ]
    page.headTitle.text = page.bodyTitle.text = ( "Christmas Bird "
        "Count: Regional index for %s" % region.reg_name)