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

8.13. RegArgs.__init__()

regx.cgi
# - - -   R e g A r g s . _ _ i n i t _ _

    def __init__(self):
        '''Constructor.
        '''
        #-- 1
        if RegArgs.initialized:
            return
        else:
            RegArgs.initialized = True

        #-- 2
        # [ form  :=  the CGI arguments to this script as a
        #       cgi.FieldStorage() instance ]
        form = cgi.FieldStorage()

For the constants that define the names of the input form elements of interest, see Section 7, “topform.py: Form constants for the top-level page”.

regx.cgi
        #-- 3
        # [ if form[topform.REG_RADIOS] is a valid region code ->
        #     self.reg_code  :=  that value, uppercased
        #   else -> raise ScriptError ]
        try:
            rawRegCode = form[topform.REG_RADIOS].value
            m = RegArgs.REG_CODE_PAT.match(rawRegCode)
            if m is None:
                raise lib.ScriptError("Not a syntactically valid "
                                      "region code.")
            self.reg_code = rawRegCode.upper()
        except KeyError:
            raise lib.ScriptError("The region code is required.")

The first and last year number elements are optional. See Section 54, “yearCheck(): Validate a year number form entry”. Year numbers are always formatted in year-number format; see Section 14.4, “year-number.

regx.cgi
        #-- 4
        # [ if FIRST_YEAR_ENTRY is not in form ->
        #       self.firstYear  :=  lib.MIN_YEAR
        #   else if it present and valid ->
        #     self.firstYear  :=  its value in year-number format
        #   else -> raise ScriptError ]
        self.firstYear = lib.yearCheck(form, topform.FIRST_YEAR_ENTRY,
            "First year number", lib.MIN_YEAR)

        #-- 5
        # [ if LAST_YEAR_ENTRY is not in form ->
        #       self.lastYear  :=  lib.MAX_YEAR
        #   else if it present and valid ->
        #     self.lastYear  :=  its value in year-number format
        #   else -> raise ScriptError ]
        self.lastYear = lib.yearCheck(form, topform.LAST_YEAR_ENTRY,
            "Last year number", lib.MAX_YEAR)

Check to see if the overlap report was requested.

regx.cgi
        #-- 6
        self.isOverlap = topform.OVERLAP_CB in form