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

8.12. class RegArgs: The CGI arguments

This class uses the Singleton design pattern so that the first constructor call processes all the CGI arguments and either returns an instance, or raises ScriptError if there is any problem. Successive calls to the constructor return the same instance.

# - - - - -   c l a s s   R e g A r g s

class RegArgs(singleton.Singleton):
    '''Represents the CGI arguments.

          [ if the CGI arguments to this script are valid ->
              return the singleton RegArgs instance representing
              those arguments
            else -> raise ScriptError ]
          [ if a valid FIRST_YEAR_ENTRY value was specified ->
              that number in year-number format
            else -> lib.MIN_YEAR ]
          [ if a valid LAST_YEAR_ENTRY value was specified ->
              that number in year-number format
            else -> lib.MAX_YEAR ]
          [ the required REG_RADIOS value ]
          [ True iff overlap report requested ]

          [ a compiled regex that matches valid region codes ]
    initialized = False

For year-number format, see Section 14.4, “year-number.

The REG_CODE_PAT class constant is a compiled regular expression used to check region codes for validity: they must consist of exactly two letters. The final “$” insures that the entire string is matched.

    REG_CODE_PAT = re.compile(r'[a-zA-Z]{2}$')